Package org.apache.juneau.reflect
Class AnnotationInfo<T extends Annotation>
java.lang.Object
org.apache.juneau.reflect.AnnotationInfo<T>
- Type Parameters:
T
- The annotation type.
Represents an annotation instance on a class and the class it was found on.
See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaccept
(Predicate<AnnotationInfo<?>> test, Consumer<AnnotationInfo<?>> action) Performs an action on this object if the specified predicate test passes.<V> AnnotationInfo<?>
forEachValue
(Class<V> type, String name, Predicate<V> test, Consumer<V> action) Performs an action on all matching values on this annotation.getApplies
(VarResolverSession vrs, Consumer<AnnotationApplier<Annotation, Object>> consumer) If this annotation has aContextApply
annotation, consumes an instance of the specifiedAnnotationApplier
class.Returns the class that this annotation was found on.Returns the class where the annotation was found.Returns the method where the annotation was found.getName()
Returns the class name of the annotation.Returns the package where the annotation was found.<V> Optional<V>
Returns a matching value on this annotation.<A extends Annotation>
booleanhasAnnotation
(Class<A> type) Returnstrue if this annotation has the specified annotation defined on it.inner()
Returns the annotation found.<A extends Annotation>
booleanReturnstrue if this annotation is in the specifiedgroup
.<A extends Annotation>
booleanReturnstrue if this annotation is the specified type.boolean
matches
(Predicate<AnnotationInfo<?>> test) Returnstrue if this object passes the specified predicate test.static <A extends Annotation>
AnnotationInfo<A>Convenience constructor when annotation is found on a package.static <A extends Annotation>
AnnotationInfo<A>Convenience constructor when annotation is found on a class.static <A extends Annotation>
AnnotationInfo<A>of
(MethodInfo onMethod, A value) Convenience constructor when annotation is found on a method.Converts this object to a readable JSON object for debugging purposes.toString()
-
Method Details
-
of
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
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
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
Returns the annotation found.- Returns:
- The annotation found.
-
getName
Returns the class name of the annotation.- Returns:
- The simple class name of the annotation.
-
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
public AnnotationInfo<T> getApplies(VarResolverSession vrs, Consumer<AnnotationApplier<Annotation, Object>> consumer) throws ExecutableExceptionIf this annotation has aContextApply
annotation, consumes an instance of the specifiedAnnotationApplier
class.- Parameters:
vrs
- Variable resolver passed to theAnnotationApplier
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
Returnstrue 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
Returnstrue 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
Returnstrue if this annotation is in the specifiedgroup
.- Type Parameters:
A
- The annotation class.- Parameters:
group
- The group annotation.- Returns:
true if this annotation is in the specifiedgroup
.
-
matches
Returnstrue 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
public AnnotationInfo<?> accept(Predicate<AnnotationInfo<?>> test, Consumer<AnnotationInfo<?>> action) 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 benull .action
- An action to perform on this object.- Returns:
- This object.
-
toString
-
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 benull .action
- An action to perform on the value.- Returns:
- This object.
-
getValue
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 benull .- Returns:
- This object.
-