public final class AnnotationMetadataHierarchy extends Object implements AnnotationMetadata, Iterable<AnnotationMetadata>
AnnotationMetadata instance passed
to the constructor represents the annotation metadata that is declared, hence methods like hasDeclaredAnnotation(String) will return true for the last annotation metadata passed in the hierarchy.
This class is used to internally optimize memory usage and compilation time for classes that declare AOP advice at the type level and where the classes methods typically don't include any annotations and therefore would be wasteful to generate additional annotation metadata classes.
| Modifier and Type | Field and Description |
|---|---|
static AnnotationMetadata[] |
EMPTY_HIERARCHY
Constant to represent an empty hierarchy.
|
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBEREMPTY| Constructor and Description |
|---|
AnnotationMetadataHierarchy(AnnotationMetadata... hierarchy)
Default constructor.
|
| Modifier and Type | Method and Description |
|---|---|
Optional<Boolean> |
booleanValue(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the boolean value and optionally map its value.
|
Optional<Boolean> |
booleanValue(String annotation,
String member)
The value as an optional boolean for the given annotation and member.
|
Optional<Boolean> |
booleanValue(String annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the boolean value and optionally map its value.
|
Optional<Class> |
classValue(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the class value and optionally map its value.
|
Optional<Class> |
classValue(String annotation,
String member)
The value of the annotation as a Class.
|
Optional<Class> |
classValue(String annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the class value and optionally map its value.
|
<T> Class<T>[] |
classValues(String annotation,
String member)
The value of the annotation as a Class.
|
AnnotationMetadata |
createSibling(AnnotationMetadata child)
Create a new hierarchy instance from this metadata using this metadata's parents.
|
OptionalDouble |
doubleValue(Class<? extends Annotation> annotation,
String member)
The value as an
OptionalDouble for the given annotation and member. |
OptionalDouble |
doubleValue(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the double value and optionally map its value.
|
OptionalDouble |
doubleValue(String annotation,
String member)
The value as an
OptionalDouble for the given annotation and member. |
OptionalDouble |
doubleValue(String annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the double value and optionally map its value.
|
<E extends Enum> |
enumValue(Class<? extends Annotation> annotation,
String member,
Class<E> enumType)
The value of the annotation as a Class.
|
<E extends Enum> |
enumValue(Class<? extends Annotation> annotation,
String member,
Class<E> enumType,
Function<Object,Object> valueMapper)
Retrieve the enum value and optionally map its value.
|
<E extends Enum> |
enumValue(String annotation,
String member,
Class<E> enumType,
Function<Object,Object> valueMapper)
Retrieve the enum value and optionally map its value.
|
<E extends Enum> |
enumValues(Class<? extends Annotation> annotation,
String member,
Class<E> enumType,
Function<Object,Object> valueMapper)
Retrieve the enum values and optionally map its value.
|
<E extends Enum> |
enumValues(String annotation,
String member,
Class<E> enumType,
Function<Object,Object> valueMapper)
Retrieve the enum values and optionally map its value.
|
<T extends Annotation> |
findAnnotation(String annotation)
Find an
AnnotationValue for the given annotation name. |
<T extends Annotation> |
findDeclaredAnnotation(String annotation)
Get all of the values for the given annotation that are directly declared on the annotated element.
|
Set<String> |
getAnnotationNames()
All the annotation names this metadata declares.
|
List<String> |
getAnnotationNamesByStereotype(String stereotype)
Resolve all of the annotation names that feature the given stereotype.
|
Optional<Class<? extends Annotation>> |
getAnnotationType(String name)
Gets the type for a given annotation if it is present on the classpath.
|
<T extends Annotation> |
getAnnotationValuesByType(Class<T> annotationType)
Gets all the annotation values by the given repeatable type.
|
Set<String> |
getDeclaredAnnotationNames()
All the declared annotation names this metadata declares.
|
<T extends Annotation> |
getDeclaredAnnotationValuesByType(Class<T> annotationType)
Gets only declared annotation values by the given repeatable type.
|
AnnotationMetadata |
getDeclaredMetadata() |
<T> Optional<T> |
getDefaultValue(String annotation,
String member,
Argument<T> requiredType)
Return the default value for the given annotation member.
|
Map<String,Object> |
getDefaultValues(String annotation)
Return the default values for the given annotation name.
|
AnnotationMetadata |
getRootMetadata() |
<T> Optional<T> |
getValue(String annotation,
String member,
Argument<T> requiredType,
Function<Object,Object> valueMapper)
Resolves the given value performing type conversion as necessary.
|
<T> OptionalValues<T> |
getValues(String annotation,
Class<T> valueType)
Get all of the values for the given annotation and type of the underlying values.
|
boolean |
hasAnnotation(String annotation)
Checks whether this object has the given annotation on the object itself or inherited from a parent.
|
boolean |
hasDeclaredAnnotation(String annotation)
Checks whether this object has the given annotation 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
|
boolean |
hasStereotype(String annotation)
Checks whether this object has the given annotation stereotype on the object itself or inherited from a parent
|
OptionalInt |
intValue(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the int value and optionally map its value.
|
OptionalInt |
intValue(String annotation,
String member)
The value as an
OptionalInt for the given annotation and member. |
OptionalInt |
intValue(String annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the int value and optionally map its value.
|
boolean |
isTrue(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the boolean value and optionally map its value.
|
boolean |
isTrue(String annotation,
String member)
Returns whether the value of the given member is true.
|
boolean |
isTrue(String annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the boolean value and optionally map its value.
|
Iterator<AnnotationMetadata> |
iterator() |
OptionalLong |
longValue(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the long value and optionally map its value.
|
OptionalLong |
longValue(String annotation,
String member)
The value as an
OptionalLong for the given annotation and member. |
OptionalLong |
longValue(String annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the long value and optionally map its value.
|
Optional<String> |
stringValue(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the string value and optionally map its value.
|
Optional<String> |
stringValue(String annotation,
String member)
The value as an optional string for the given annotation and member.
|
Optional<String> |
stringValue(String annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the string value and optionally map its value.
|
String[] |
stringValues(Class<? extends Annotation> annotation,
String member)
The values as string array for the given annotation and member.
|
String[] |
stringValues(Class<? extends Annotation> annotation,
String member,
Function<Object,Object> valueMapper)
Retrieve the string value and optionally map its value.
|
<T extends Annotation> |
synthesize(Class<T> annotationClass)
Synthesizes a new annotation from the metadata for the given annotation type.
|
<T extends Annotation> |
synthesizeDeclared(Class<T> annotationClass)
Synthesizes a new annotation from the metadata for the given annotation type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitbooleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValues, classValues, classValues, doubleValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findDeclaredAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNamesByStereotype, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDefaultValue, getDefaultValue, getDefaultValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, hasAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isTrue, longValue, stringValue, stringValue, stringValue, stringValuesgetAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclaredAnnotationsByTypeforEach, spliteratorpublic static final AnnotationMetadata[] EMPTY_HIERARCHY
public AnnotationMetadataHierarchy(AnnotationMetadata... hierarchy)
hierarchy - The annotation hierarchypublic Optional<Class<? extends Annotation>> getAnnotationType(@Nonnull String name)
AnnotationMetadatagetAnnotationType in interface AnnotationMetadataname - The type name@Nonnull public AnnotationMetadata getDeclaredMetadata()
@Nonnull public AnnotationMetadata getRootMetadata()
@Nonnull public AnnotationMetadata createSibling(@Nonnull AnnotationMetadata child)
child - The child annotation metadata@Nullable public <T extends Annotation> T synthesize(@Nonnull Class<T> annotationClass)
AnnotationSourcesynthesize in interface AnnotationSourceT - The annotation generic typeannotationClass - The annotation class@Nullable public <T extends Annotation> T synthesizeDeclared(@Nonnull Class<T> annotationClass)
AnnotationSourceThis method ignores inherited annotations. (Returns null if no annotations are directly present on this element.)
synthesizeDeclared in interface AnnotationSourceT - The annotation generic typeannotationClass - The annotation class@Nonnull public <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(@Nonnull String annotation)
AnnotationSourceAnnotationValue for the given annotation name.findAnnotation in interface AnnotationSourceT - The annotation typeannotation - The annotation nameAnnotationValue instance@Nonnull public <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(@Nonnull String annotation)
AnnotationSourcefindDeclaredAnnotation in interface AnnotationSourceT - The annotation typeannotation - The annotation nameAnnotationValue instance@Nonnull public OptionalDouble doubleValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member)
AnnotationMetadataOptionalDouble for the given annotation and member.doubleValue in interface AnnotationMetadataannotation - The annotationmember - The memberOptionalDouble value@Nonnull public String[] stringValues(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member)
AnnotationMetadatastringValues in interface AnnotationMetadataannotation - The annotationmember - The memberpublic Optional<Boolean> booleanValue(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadatabooleanValue in interface AnnotationMetadataannotation - The annotationmember - The memberpublic boolean isTrue(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadataisTrue in interface AnnotationMetadataannotation - The annotation classmember - The annotation memberpublic OptionalLong longValue(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadataOptionalLong for the given annotation and member.longValue in interface AnnotationMetadataannotation - The annotationmember - The memberOptionalLong valuepublic Optional<String> stringValue(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadatastringValue in interface AnnotationMetadataannotation - The annotationmember - The memberpublic OptionalInt intValue(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadataOptionalInt for the given annotation and member.intValue in interface AnnotationMetadataannotation - The annotationmember - The memberOptionalInt value@Nonnull public OptionalDouble doubleValue(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadataOptionalDouble for the given annotation and member.doubleValue in interface AnnotationMetadataannotation - The annotationmember - The memberOptionalDouble valuepublic <E extends Enum> Optional<E> enumValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Class<E> enumType)
AnnotationMetadataenumValue in interface AnnotationMetadataE - The enum typeannotation - The annotationmember - The annotation memberenumType - The enum typeOptional class@Nonnull public <T> Class<T>[] classValues(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadataclassValues in interface AnnotationMetadataT - The type of the classannotation - The annotationmember - The annotation memberOptional classpublic Optional<Class> classValue(@Nonnull String annotation, @Nonnull String member)
AnnotationMetadataclassValue in interface AnnotationMetadataannotation - The annotationmember - The annotation memberOptional class@Nonnull public List<String> getAnnotationNamesByStereotype(@Nullable String stereotype)
AnnotationMetadatagetAnnotationNamesByStereotype in interface AnnotationMetadatastereotype - The annotation names@Nonnull public Set<String> getDeclaredAnnotationNames()
AnnotationMetadatagetDeclaredAnnotationNames in interface AnnotationMetadata@Nonnull public Set<String> getAnnotationNames()
AnnotationMetadatagetAnnotationNames in interface AnnotationMetadata@Nonnull public <T> OptionalValues<T> getValues(@Nonnull String annotation, @Nonnull Class<T> valueType)
AnnotationMetadatagetValues in interface AnnotationMetadataT - Generic typeannotation - The annotation namevalueType - valueTypeOptionalValuespublic <T> Optional<T> getDefaultValue(@Nonnull String annotation, @Nonnull String member, @Nonnull Argument<T> requiredType)
AnnotationMetadatagetDefaultValue in interface AnnotationMetadataT - The required generic typeannotation - The annotationmember - The memberrequiredType - The required type@Nonnull public <T extends Annotation> List<AnnotationValue<T>> getAnnotationValuesByType(@Nonnull Class<T> annotationType)
AnnotationMetadatagetAnnotationValuesByType in interface AnnotationMetadataT - The annotation typeannotationType - The annotation type@Nonnull public <T extends Annotation> List<AnnotationValue<T>> getDeclaredAnnotationValuesByType(@Nonnull Class<T> annotationType)
AnnotationMetadatagetDeclaredAnnotationValuesByType in interface AnnotationMetadataT - The annotation typeannotationType - The annotation typepublic boolean hasDeclaredAnnotation(@Nullable String annotation)
AnnotationMetadatahasDeclaredAnnotation in interface AnnotationMetadataannotation - The annotationpublic boolean hasAnnotation(@Nullable String annotation)
AnnotationMetadatahasAnnotation in interface AnnotationMetadataannotation - The annotationpublic boolean hasStereotype(@Nullable String annotation)
AnnotationMetadataChecks 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
hasStereotype in interface AnnotationMetadataannotation - The annotationpublic boolean hasDeclaredStereotype(@Nullable String annotation)
AnnotationMetadataChecks 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
hasDeclaredStereotype in interface AnnotationMetadataannotation - The annotation@Nonnull public Map<String,Object> getDefaultValues(@Nonnull String annotation)
AnnotationMetadatagetDefaultValues in interface AnnotationMetadataannotation - The annotation namepublic <E extends Enum> Optional<E> enumValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Class<E> enumType, @Nullable Function<Object,Object> valueMapper)
E - The enum typeannotation - The annotationmember - The memberenumType - The enum typevalueMapper - The value mapperpublic <E extends Enum> Optional<E> enumValue(@Nonnull String annotation, @Nonnull String member, Class<E> enumType, @Nullable Function<Object,Object> valueMapper)
E - The enum typeannotation - The annotationmember - The memberenumType - The enum typevalueMapper - The value mapperpublic <E extends Enum> E[] enumValues(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Class<E> enumType, @Nullable Function<Object,Object> valueMapper)
E - The enum typeannotation - The annotationmember - The memberenumType - The enum typevalueMapper - The value mapperpublic <E extends Enum> E[] enumValues(@Nonnull String annotation, @Nonnull String member, Class<E> enumType, @Nullable Function<Object,Object> valueMapper)
E - The enum typeannotation - The annotationmember - The memberenumType - The enum typevalueMapper - The value mapperpublic Optional<Class> classValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic Optional<Class> classValue(@Nonnull String annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic OptionalInt intValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic Optional<Boolean> booleanValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapper@Nonnull public Optional<Boolean> booleanValue(@Nonnull String annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic OptionalLong longValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapper@Nonnull public OptionalLong longValue(@Nonnull String annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapper@Nonnull public OptionalInt intValue(@Nonnull String annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic Optional<String> stringValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapper@Nonnull public String[] stringValues(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapper@Nonnull public Optional<String> stringValue(@Nonnull String annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic boolean isTrue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic boolean isTrue(@Nonnull String annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapperpublic OptionalDouble doubleValue(@Nonnull Class<? extends Annotation> annotation, @Nonnull String member, @Nullable Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapper@Nonnull public OptionalDouble doubleValue(@Nonnull String annotation, @Nonnull String member, Function<Object,Object> valueMapper)
annotation - The annotationmember - The membervalueMapper - The value mapper@Nonnull public <T> Optional<T> getValue(@Nonnull String annotation, @Nonnull String member, @Nonnull Argument<T> requiredType, @Nullable Function<Object,Object> valueMapper)
T - The generic typeannotation - The annotationmember - The memberrequiredType - The required typevalueMapper - The value mapper@NotNull public Iterator<AnnotationMetadata> iterator()
iterator in interface Iterable<AnnotationMetadata>