public interface AnnotationMetadata extends AnnotationSource
An interface implemented at compile time by Micronaut that allows the inspection of annotation metadata and stereotypes (meta-annotations)
.
This interface exposes fast and efficient means to expose annotation data at runtime without requiring reflective tricks to read the annotation metadata
Users of Micronaut should in general avoid the methods of the AnnotatedElement
interface and use this interface instead to obtain maximum efficiency
Core framework types such as io.micronaut.inject.BeanDefinition and io.micronaut.inject.ExecutableMethod implement this interface
Modifier and Type | Field and Description |
---|---|
static String |
CLASS_NAME_SUFFIX
The suffix used when saving compiled metadata to classes.
|
static AnnotationMetadata |
EMPTY_METADATA
A constant for representing empty metadata.
|
static String |
VALUE_MEMBER
The default value() member.
|
EMPTY
Modifier and Type | Method and Description |
---|---|
default Optional<Class> |
classValue(Class<? extends Annotation> annotation)
The value of the annotation as a Class.
|
default Optional<Class> |
classValue(Class<? extends Annotation> annotation,
String member)
The value of the annotation as a Class.
|
default Optional<Class> |
classValue(String annotation)
The value of the annotation as a Class.
|
default Optional<Class> |
classValue(String annotation,
String member)
The value of the annotation as a Class.
|
default OptionalDouble |
doubleValue(String annotation,
String member)
The value as an
OptionalDouble for the given annotation and member. |
default <T extends Annotation> |
findAnnotation(Class<T> annotation)
Get all of the values for the given annotation.
|
default <T extends Annotation> |
findDeclaredAnnotation(Class<T> annotation)
Get all of the values for the given annotation that are directly declared on the annotated element.
|
default Optional<String> |
getAnnotationNameByStereotype(Class<? extends Annotation> stereotype)
Find the first annotation name for the given stereotype.
|
default Optional<String> |
getAnnotationNameByStereotype(String stereotype)
Find the first annotation name for the given stereotype.
|
Set<String> |
getAnnotationNames()
All the annotation names this metadata declares.
|
default List<String> |
getAnnotationNamesByStereotype(Class<? extends Annotation> stereotype)
Resolve all of the annotation names that feature the given stereotype.
|
List<String> |
getAnnotationNamesByStereotype(String stereotype)
Resolve all of the annotation names that feature the given stereotype.
|
default Optional<Class<? extends Annotation>> |
getAnnotationType(String name)
Gets the type for a given annotation if it is present on the classpath.
|
default Optional<Class<? extends Annotation>> |
getAnnotationTypeByStereotype(Class<? extends Annotation> stereotype)
Find the first annotation name for the given stereotype.
|
default Optional<Class<? extends Annotation>> |
getAnnotationTypeByStereotype(String stereotype)
Find the first annotation name for the given stereotype.
|
default List<Class<? extends Annotation>> |
getAnnotationTypesByStereotype(Class<? extends Annotation> stereotype)
Resolve all of the annotation names that feature the given stereotype.
|
<T extends Annotation> |
getAnnotationValuesByType(Class<T> annotationType)
Gets all the annotation values by the given repeatable type.
|
default Optional<String> |
getDeclaredAnnotationNameByStereotype(String stereotype)
Find the first annotation name for the given stereotype.
|
Set<String> |
getDeclaredAnnotationNames()
All the declared annotation names this metadata declares.
|
List<String> |
getDeclaredAnnotationNamesByStereotype(String stereotype)
Resolve all of the annotations names for the given stereotype that are declared annotations.
|
default Optional<Class<? extends Annotation>> |
getDeclaredAnnotationTypeByStereotype(Class<? extends Annotation> stereotype)
Find the first declared annotation name for the given stereotype.
|
default Optional<Class<? extends Annotation>> |
getDeclaredAnnotationTypeByStereotype(String stereotype)
Find the first annotation name for the given stereotype.
|
<T extends Annotation> |
getDeclaredAnnotationValuesByType(Class<T> annotationType)
Gets only declared annotation values by the given repeatable type.
|
default <T> Optional<T> |
getDefaultValue(Class<? extends Annotation> annotation,
String member,
Argument<T> requiredType)
Return the default value for the given annotation member.
|
default <T> Optional<T> |
getDefaultValue(Class<? extends Annotation> annotation,
String member,
Class<T> requiredType)
Return the default value for the given annotation member.
|
<T> Optional<T> |
getDefaultValue(String annotation,
String member,
Argument<T> requiredType)
Return the default value for the given annotation member.
|
default <T> Optional<T> |
getDefaultValue(String annotation,
String member,
Class<T> requiredType)
Return the default value for the given annotation member.
|
default Optional<Object> |
getValue(Class<? extends Annotation> annotation)
Get the value of default "value" the given annotation.
|
default <T> Optional<T> |
getValue(Class<? extends Annotation> annotation,
Argument<T> requiredType)
Get the value of default "value" the given annotation.
|
default <T> Optional<T> |
getValue(Class<? extends Annotation> annotation,
Class<T> requiredType)
Get the value of default "value" the given annotation.
|
default Optional<Object> |
getValue(Class<? extends Annotation> annotation,
String member)
Get the value of the given annotation member.
|
default <T> Optional<T> |
getValue(Class<? extends Annotation> annotation,
String member,
Argument<T> requiredType)
Get the value of the given annotation member.
|
default <T> Optional<T> |
getValue(Class<? extends Annotation> annotation,
String member,
Class<T> requiredType)
Get the value of the given annotation member.
|
default Optional<Object> |
getValue(String annotation)
Get the value of default "value" the given annotation.
|
default <T> Optional<T> |
getValue(String annotation,
Argument<T> requiredType)
Get the value of default "value" the given annotation.
|
default <T> Optional<T> |
getValue(String annotation,
Class<T> requiredType)
Get the value of default "value" the given annotation.
|
default Optional<Object> |
getValue(String annotation,
String member)
Get the value of the given annotation member.
|
default <T> Optional<T> |
getValue(String annotation,
String member,
Argument<T> requiredType)
Get the value of the given annotation member.
|
default <T> Optional<T> |
getValue(String annotation,
String member,
Class<T> requiredType)
Get the value of the given annotation member.
|
default <T> OptionalValues<T> |
getValues(Class<? extends Annotation> annotation,
Class<T> valueType)
Get all of the values for the given annotation.
|
<T> OptionalValues<T> |
getValues(String annotation,
Class<T> valueType)
Get all of the values for the given annotation and type of the underlying values.
|
default boolean |
hasAnnotation(Class<? extends Annotation> annotation)
Checks whether this object has the given annotation on the object itself or inherited from a parent.
|
boolean |
hasAnnotation(String annotation)
Checks whether this object has the given annotation on the object itself or inherited from a parent.
|
default boolean |
hasDeclaredAnnotation(Class<? extends Annotation> annotation)
Checks whether this object has the given annotation directly declared on the object.
|
boolean |
hasDeclaredAnnotation(String annotation)
Checks whether this object has the given annotation directly declared on the object.
|
default boolean |
hasDeclaredStereotype(Class<? extends Annotation>... annotations)
Checks whether this object has any of the given stereotype directly declared on the object.
|
default boolean |
hasDeclaredStereotype(Class<? extends Annotation> stereotype)
Checks whether this object has the given stereotype directly declared on the object.
|
boolean |
hasDeclaredStereotype(String annotation)
Checks whether this object has the given annotation stereotype on the object itself and not inherited from a parent
|
default boolean |
hasStereotype(Class<? extends Annotation>... annotations)
Check whether any of the given stereotypes is present.
|
default boolean |
hasStereotype(Class<? extends Annotation> annotation)
Checks whether this object has the given annotation stereotype on the object itself or inherited from a parent
|
boolean |
hasStereotype(String annotation)
Checks whether this object has the given annotation stereotype on the object itself or inherited from a parent
|
default boolean |
hasStereotype(String[] annotations)
Check whether any of the given stereotypes is present.
|
default OptionalInt |
intValue(String annotation,
String member)
The value as an
OptionalInt for the given annotation and member. |
default boolean |
isAnnotationPresent(Class<? extends Annotation> annotationClass)
Return whether an annotation is present.
|
default boolean |
isDeclaredAnnotationPresent(Class<? extends Annotation> annotationClass)
Variation of
AnnotationSource.isAnnotationPresent(Class) for declared annotations. |
default boolean |
isEmpty()
Is the annotation metadata empty.
|
default boolean |
isFalse(Class<? extends Annotation> annotation,
String member)
Returns whether the value of the given member is true.
|
default boolean |
isFalse(String annotation,
String member)
Returns whether the value of the given member is true.
|
default boolean |
isPresent(Class<? extends Annotation> annotation,
String member)
Returns whether the value of the given member is true.
|
default boolean |
isPresent(String annotation,
String member)
Returns whether the value of the given member is present.
|
default boolean |
isTrue(Class<? extends Annotation> annotation,
String member)
Returns whether the value of the given member is true.
|
default boolean |
isTrue(String annotation,
String member)
Returns whether the value of the given member is true.
|
default OptionalLong |
longValue(String annotation,
String member)
The value as an
OptionalLong for the given annotation and member. |
findAnnotation, findDeclaredAnnotation, getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
static final AnnotationMetadata EMPTY_METADATA
static final String VALUE_MEMBER
static final String CLASS_NAME_SUFFIX
boolean hasDeclaredAnnotation(@Nullable String annotation)
annotation
- The annotationboolean hasAnnotation(@Nullable String annotation)
annotation
- The annotationboolean hasStereotype(@Nullable String annotation)
Checks whether this object has the given annotation stereotype on the object itself or inherited from a parent
.
An annotation stereotype is a meta annotation potentially applied to another annotation
annotation
- The annotationboolean hasDeclaredStereotype(@Nullable String annotation)
Checks whether this object has the given annotation stereotype on the object itself and not inherited from a parent
.
An annotation stereotype is a meta annotation potentially applied to another annotation
annotation
- The annotationList<String> getAnnotationNamesByStereotype(String stereotype)
stereotype
- The annotation namesSet<String> getAnnotationNames()
Set<String> getDeclaredAnnotationNames()
List<String> getDeclaredAnnotationNamesByStereotype(String stereotype)
stereotype
- The stereotype<T> OptionalValues<T> getValues(String annotation, Class<T> valueType)
T
- Generic typeannotation
- The annotation namevalueType
- valueTypeOptionalValues
<T> Optional<T> getDefaultValue(String annotation, String member, Argument<T> requiredType)
T
- The required generic typeannotation
- The annotationmember
- The memberrequiredType
- The required type<T extends Annotation> List<AnnotationValue<T>> getAnnotationValuesByType(Class<T> annotationType)
T
- The annotation typeannotationType
- The annotation type<T extends Annotation> List<AnnotationValue<T>> getDeclaredAnnotationValuesByType(Class<T> annotationType)
T
- The annotation typeannotationType
- The annotation typedefault <T> Optional<T> getDefaultValue(String annotation, String member, Class<T> requiredType)
T
- The required generic typeannotation
- The annotationmember
- The memberrequiredType
- The required typedefault <T> Optional<T> getDefaultValue(Class<? extends Annotation> annotation, String member, Argument<T> requiredType)
T
- The required generic typeannotation
- The annotationmember
- The memberrequiredType
- The required typedefault boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
AnnotationSource
isAnnotationPresent
in interface AnnotationSource
annotationClass
- The annotation classAnnotationSource.isAnnotationPresent(Class)
default boolean isDeclaredAnnotationPresent(Class<? extends Annotation> annotationClass)
AnnotationSource
AnnotationSource.isAnnotationPresent(Class)
for declared annotations.isDeclaredAnnotationPresent
in interface AnnotationSource
annotationClass
- The annotation classAnnotationSource.isAnnotationPresent(Class)
default <T> Optional<T> getDefaultValue(Class<? extends Annotation> annotation, String member, Class<T> requiredType)
T
- The required generic typeannotation
- The annotationmember
- The memberrequiredType
- The required typedefault <T> Optional<T> getValue(Class<? extends Annotation> annotation, String member, Class<T> requiredType)
T
- The valueannotation
- The annotation classmember
- The annotation memberrequiredType
- The required typeOptional
of the valuedefault <T> Optional<T> getValue(Class<? extends Annotation> annotation, String member, Argument<T> requiredType)
T
- The valueannotation
- The annotation classmember
- The annotation memberrequiredType
- The required typeOptional
of the valuedefault Optional<String> getAnnotationNameByStereotype(String stereotype)
stereotype
- The stereotypedefault Optional<String> getDeclaredAnnotationNameByStereotype(String stereotype)
stereotype
- The stereotypedefault Optional<Class<? extends Annotation>> getAnnotationTypeByStereotype(Class<? extends Annotation> stereotype)
stereotype
- The stereotypedefault Optional<Class<? extends Annotation>> getDeclaredAnnotationTypeByStereotype(Class<? extends Annotation> stereotype)
stereotype
- The stereotypedefault Optional<Class<? extends Annotation>> getDeclaredAnnotationTypeByStereotype(String stereotype)
stereotype
- The stereotypedefault Optional<Class<? extends Annotation>> getAnnotationType(String name)
name
- The type namedefault Optional<Class<? extends Annotation>> getAnnotationTypeByStereotype(String stereotype)
stereotype
- The stereotypedefault Optional<String> getAnnotationNameByStereotype(Class<? extends Annotation> stereotype)
stereotype
- The stereotypedefault <T> OptionalValues<T> getValues(Class<? extends Annotation> annotation, Class<T> valueType)
T
- Generic typeannotation
- The annotation namevalueType
- valueTypeOptionalValues
default List<String> getAnnotationNamesByStereotype(Class<? extends Annotation> stereotype)
stereotype
- The annotation namesdefault List<Class<? extends Annotation>> getAnnotationTypesByStereotype(Class<? extends Annotation> stereotype)
stereotype
- The annotation namesdefault <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(Class<T> annotation)
findAnnotation
in interface AnnotationSource
T
- The annotation typeannotation
- The annotation nameAnnotationValue
default <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(Class<T> annotation)
findDeclaredAnnotation
in interface AnnotationSource
T
- The annotation typeannotation
- The annotation nameAnnotationValue
instancedefault <T> Optional<T> getValue(String annotation, String member, Class<T> requiredType)
T
- The valueannotation
- The annotation classmember
- The annotation memberrequiredType
- The required typeOptional
of the valuedefault <T> Optional<T> getValue(String annotation, String member, Argument<T> requiredType)
T
- The valueannotation
- The annotation classmember
- The annotation memberrequiredType
- The required typeOptional
of the valuedefault OptionalLong longValue(String annotation, String member)
OptionalLong
for the given annotation and member.annotation
- The annotationmember
- The memberOptionalLong
valuedefault Optional<Class> classValue(String annotation)
annotation
- The annotationOptional
classdefault Optional<Class> classValue(String annotation, String member)
annotation
- The annotationmember
- The annotation memberOptional
classdefault Optional<Class> classValue(Class<? extends Annotation> annotation)
annotation
- The annotationOptional
classdefault Optional<Class> classValue(Class<? extends Annotation> annotation, String member)
annotation
- The annotationmember
- The annotation memberOptional
classdefault OptionalInt intValue(String annotation, String member)
OptionalInt
for the given annotation and member.annotation
- The annotationmember
- The memberOptionalInt
valuedefault OptionalDouble doubleValue(String annotation, String member)
OptionalDouble
for the given annotation and member.annotation
- The annotationmember
- The memberOptionalDouble
valuedefault <T> Optional<T> getValue(String annotation, Class<T> requiredType)
T
- The valueannotation
- The annotation classrequiredType
- The required typeOptional
of the valuedefault Optional<Object> getValue(String annotation, String member)
annotation
- The annotation classmember
- The annotation memberOptional
of the valuedefault Optional<Object> getValue(Class<? extends Annotation> annotation, String member)
annotation
- The annotation classmember
- The annotation memberOptional
of the valuedefault boolean isTrue(String annotation, String member)
annotation
- The annotation classmember
- The annotation memberdefault boolean isTrue(Class<? extends Annotation> annotation, String member)
annotation
- The annotation classmember
- The annotation memberdefault boolean isPresent(String annotation, String member)
annotation
- The annotation classmember
- The annotation memberdefault boolean isPresent(Class<? extends Annotation> annotation, String member)
annotation
- The annotation classmember
- The annotation memberdefault boolean isFalse(Class<? extends Annotation> annotation, String member)
annotation
- The annotation classmember
- The annotation memberdefault boolean isFalse(String annotation, String member)
annotation
- The annotation classmember
- The annotation memberdefault Optional<Object> getValue(String annotation)
annotation
- The annotation classOptional
of the valuedefault Optional<Object> getValue(Class<? extends Annotation> annotation)
annotation
- The annotation classOptional
of the valuedefault <T> Optional<T> getValue(Class<? extends Annotation> annotation, Class<T> requiredType)
T
- Generic typeannotation
- The annotation classrequiredType
- requiredTypeOptional
of the valuedefault <T> Optional<T> getValue(Class<? extends Annotation> annotation, Argument<T> requiredType)
T
- Generic typeannotation
- The annotation classrequiredType
- requiredTypeOptional
of the valuedefault <T> Optional<T> getValue(String annotation, Argument<T> requiredType)
T
- Generic typeannotation
- The annotation classrequiredType
- requiredTypeOptional
of the valuedefault boolean hasAnnotation(@Nullable Class<? extends Annotation> annotation)
annotation
- The annotationdefault boolean hasStereotype(@Nullable Class<? extends Annotation> annotation)
Checks whether this object has the given annotation stereotype on the object itself or inherited from a parent
.
An annotation stereotype is a meta annotation potentially applied to another annotation
annotation
- The annotationdefault boolean hasStereotype(Class<? extends Annotation>... annotations)
annotations
- The annotationsdefault boolean hasStereotype(String[] annotations)
annotations
- The annotationsdefault boolean hasDeclaredAnnotation(@Nullable Class<? extends Annotation> annotation)
annotation
- The annotationdefault boolean hasDeclaredStereotype(@Nullable Class<? extends Annotation> stereotype)
stereotype
- The annotationdefault boolean hasDeclaredStereotype(Class<? extends Annotation>... annotations)
annotations
- The annotationsdefault boolean isEmpty()