Class AnnotationInfo<T extends Annotation>

java.lang.Object
org.apache.juneau.reflect.AnnotationInfo<T>
Type Parameters:
T - The annotation type.

public final class AnnotationInfo<T extends Annotation> extends Object
Represents an annotation instance on a class and the class it was found on.
See Also:
  • Method Details

    • of

      public static <A extends Annotation> AnnotationInfo<A> of(ClassInfo onClass, A value)
      Convenience constructor when annotation is found on a class.
      Type Parameters:
      A - The annotation class.
      Parameters:
      onClass - The class where the annotation was found.
      value - The annotation found.
      Returns:
      A new AnnotationInfo object.
    • of

      public static <A extends Annotation> AnnotationInfo<A> of(MethodInfo onMethod, A value)
      Convenience constructor when annotation is found on a method.
      Type Parameters:
      A - The annotation class.
      Parameters:
      onMethod - The method where the annotation was found.
      value - The annotation found.
      Returns:
      A new AnnotationInfo object.
    • of

      public static <A extends Annotation> AnnotationInfo<A> of(Package onPackage, A value)
      Convenience constructor when annotation is found on a package.
      Type Parameters:
      A - The annotation class.
      Parameters:
      onPackage - The package where the annotation was found.
      value - The annotation found.
      Returns:
      A new AnnotationInfo object.
    • getClassOn

      Returns the class where the annotation was found.
      Returns:
      the class where the annotation was found, or null if it wasn't found on a method.
    • getMethodOn

      Returns the method where the annotation was found.
      Returns:
      the method where the annotation was found, or null if it wasn't found on a method.
    • getPackageOn

      Returns the package where the annotation was found.
      Returns:
      the package where the annotation was found, or null if it wasn't found on a package.
    • inner

      public T inner()
      Returns the annotation found.
      Returns:
      The annotation found.
    • getName

      public String getName()
      Returns the class name of the annotation.
      Returns:
      The simple class name of the annotation.
    • toJsonMap

      public JsonMap toJsonMap()
      Converts this object to a readable JSON object for debugging purposes.
      Returns:
      A new map showing the attributes of this object as a JSON object.
    • getApplies

      If this annotation has a ContextApply annotation, consumes an instance of the specified AnnotationApplier class.
      Parameters:
      vrs - Variable resolver passed to the AnnotationApplier object.
      consumer - The consumer.
      Returns:
      This object.
      Throws:
      ExecutableException - Exception occurred on invoked constructor/method/field.
    • getClassInfo

      Returns the class that this annotation was found on.
      Returns:
      The class that this annotation was found on, or null if it was found on a package.
    • isType

      public <A extends Annotation> boolean isType(Class<A> type)
      Returns true if this annotation is the specified type.
      Type Parameters:
      A - The annotation class.
      Parameters:
      type - The type to test against.
      Returns:
      true if this annotation is the specified type.
    • hasAnnotation

      public <A extends Annotation> boolean hasAnnotation(Class<A> type)
      Returns true if this annotation has the specified annotation defined on it.
      Type Parameters:
      A - The annotation class.
      Parameters:
      type - The annotation to test for.
      Returns:
      true if this annotation has the specified annotation defined on it.
    • isInGroup

      public <A extends Annotation> boolean isInGroup(Class<A> group)
      Returns true if this annotation is in the specified group.
      Type Parameters:
      A - The annotation class.
      Parameters:
      group - The group annotation.
      Returns:
      true if this annotation is in the specified group.
    • matches

      public boolean matches(Predicate<AnnotationInfo<?>> test)
      Returns true if this object passes the specified predicate test.
      Parameters:
      test - The test to perform.
      Returns:
      true if this object passes the specified predicate test.
    • accept

      Performs an action on this object if the specified predicate test passes.
      Parameters:
      test - A test to apply to determine if action should be executed. Can be null.
      action - An action to perform on this object.
      Returns:
      This object.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • forEachValue

      public <V> AnnotationInfo<?> forEachValue(Class<V> type, String name, Predicate<V> test, Consumer<V> action)
      Performs an action on all matching values on this annotation.
      Type Parameters:
      V - The annotation field type.
      Parameters:
      type - The annotation field type.
      name - The annotation field name.
      test - A predicate to apply to the value to determine if action should be performed. Can be null.
      action - An action to perform on the value.
      Returns:
      This object.
    • getValue

      public <V> Optional<V> getValue(Class<V> type, String name, Predicate<V> test)
      Returns a matching value on this annotation.
      Type Parameters:
      V - The annotation field type.
      Parameters:
      type - The annotation field type.
      name - The annotation field name.
      test - A predicate to apply to the value to determine if value should be used. Can be null.
      Returns:
      This object.