Class AnnotationHelper

java.lang.Object
com.github.victools.jsonschema.generator.AnnotationHelper

public final class AnnotationHelper extends Object
Helper class providing with standard mechanism to resolve annotations on annotated entities.
Since:
4.37.0
  • Method Details

    • resolveAnnotation

      public static <A extends Annotation> Optional<A> resolveAnnotation(com.fasterxml.classmate.members.ResolvedMember<?> member, Class<A> annotationClass, Predicate<Annotation> metaAnnotationCheck)
      Resolves the specified annotation on the given resolved member and resolve nested annotations.
      Type Parameters:
      A - the generic type of the annotation
      Parameters:
      member - where to look for the specified annotation
      annotationClass - the class of the annotation to look for
      metaAnnotationCheck - the predicate indicating nested annotations
      Returns:
      an empty entry if not found
    • resolveAnnotation

      public static <A extends Annotation> Optional<A> resolveAnnotation(List<Annotation> annotationList, Class<A> annotationClass, Predicate<Annotation> metaAnnotationCheck)
      Select the instance of the specified annotation type from the given list.

      Also considering meta annotations (i.e., annotations on annotations) if a meta annotation is deemed eligible according to the given Predicate.

      Type Parameters:
      A - the generic type of the annotation
      Parameters:
      annotationList - a list of annotations to look into
      annotationClass - the class of the annotation to look for
      metaAnnotationCheck - the predicate indicating nested annotations
      Returns:
      an empty entry if not found
    • resolveAnnotation

      public static <A extends Annotation> Optional<A> resolveAnnotation(AnnotatedElement annotatedElement, Class<A> annotationClass, Predicate<Annotation> metaAnnotationCheck)
      Select the instance of the specified annotation type from the given annotatedElement's annotations.

      Also considering meta annotations (i.e., annotations on annotations) if a meta annotation is deemed eligible according to the given metaAnnotationPredicate.

      Type Parameters:
      A - the generic type of the annotation
      Parameters:
      annotatedElement - where to look for the specified annotation
      annotationClass - the class of the annotation to look for
      metaAnnotationCheck - the predicate indicating meta annotations
      Returns:
      an empty entry if not found