@Internal public class DefaultAnnotationMetadata extends Object implements AnnotationMetadata, Cloneable
AnnotationMetadata
.
NOTE: Although required to be public This is an internal class and should not be referenced directly in user code
Modifier and Type | Field and Description |
---|---|
protected Map<String,Annotation> |
annotationMap |
protected Map<String,Annotation> |
declaredAnnotationMap |
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
EMPTY
Modifier | Constructor and Description |
---|---|
protected |
DefaultAnnotationMetadata()
Constructs empty annotation metadata.
|
|
DefaultAnnotationMetadata(Map<String,Map<CharSequence,Object>> declaredAnnotations,
Map<String,Map<CharSequence,Object>> declaredStereotypes,
Map<String,Map<CharSequence,Object>> allStereotypes,
Map<String,Map<CharSequence,Object>> allAnnotations,
Map<String,List<String>> annotationsByStereotype)
This constructor is designed to be used by compile time produced subclasses.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addAnnotation(String annotation,
Map<CharSequence,Object> values)
Adds an annotation and its member values, if the annotation already exists the data will be merged with existing
values replaced.
|
protected void |
addAnnotationValuesFromData(List results,
Map<CharSequence,Object> values)
Adds any annotation values found in the values map to the results.
|
protected void |
addDeclaredAnnotation(String annotation,
Map<CharSequence,Object> values)
Adds an annotation directly declared on the element and its member values, if the annotation already exists the
data will be merged with existing values replaced.
|
protected void |
addDeclaredRepeatable(String annotationName,
AnnotationValue annotationValue)
Adds a repeatable annotation value.
|
protected void |
addDeclaredRepeatableStereotype(List<String> parents,
String stereotype,
AnnotationValue annotationValue)
Adds a repeatable declared stereotype value.
|
protected void |
addDeclaredStereotype(List<String> parentAnnotations,
String stereotype,
Map<CharSequence,Object> values)
Adds a stereotype and its member values, if the annotation already exists the data will be merged with existing
values replaced.
|
protected void |
addDefaultAnnotationValues(String annotation,
Map<CharSequence,Object> values)
Adds an annotation directly declared on the element and its member values, if the annotation already exists the
data will be merged with existing values replaced.
|
protected void |
addRepeatable(String annotationName,
AnnotationValue annotationValue)
Adds a repeatable annotation value.
|
protected void |
addRepeatableStereotype(List<String> parents,
String stereotype,
AnnotationValue annotationValue)
Adds a repeatable stereotype value.
|
protected void |
addStereotype(List<String> parentAnnotations,
String stereotype,
Map<CharSequence,Object> values)
Adds a stereotype and its member values, if the annotation already exists the data will be merged with existing
values replaced.
|
protected void |
addValuesToResults(List<AnnotationValue> results,
AnnotationValue values)
Adds a values instance to the results.
|
protected static boolean |
areAnnotationDefaultsRegistered(String annotation)
Returns whether annotation defaults are registered for the give annotation.
|
AnnotationMetadata |
clone() |
<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.
|
List<String> |
getDeclaredAnnotationNamesByStereotype(String stereotype)
Resolve all of the annotations names for the given stereotype that are declared annotations.
|
<T extends Annotation> |
getDeclaredAnnotationValuesByType(Class<T> annotationType)
Gets only declared annotation values by the given repeatable type.
|
<T> Optional<T> |
getDefaultValue(String annotation,
String member,
Argument<T> requiredType)
Return the default value for the given annotation member.
|
<T> Optional<T> |
getDefaultValue(String annotation,
String member,
Class<T> requiredType)
Return the default value for the given annotation member.
|
<T> Optional<T> |
getValue(Class<? extends Annotation> annotation,
String member,
Class<T> requiredType)
Get the value of the given annotation member.
|
<T> Optional<T> |
getValue(String annotation,
String member,
Argument<T> requiredType)
Get the value of the given annotation member.
|
<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
|
boolean |
isEmpty()
Is the annotation metadata empty.
|
static AnnotationMetadata |
mutateMember(AnnotationMetadata annotationMetadata,
String annotationName,
Map<CharSequence,Object> members)
Sets a member of the given
AnnotationMetadata return a new annotation metadata instance without
mutating the existing. |
static AnnotationMetadata |
mutateMember(AnnotationMetadata annotationMetadata,
String annotationName,
String member,
Object value)
Sets a member of the given
AnnotationMetadata return a new annotation metadata instance without
mutating the existing. |
protected static void |
registerAnnotationDefaults(AnnotationClassValue<?> annotation,
Map<String,Object> defaultValues)
Registers annotation default values.
|
protected static void |
registerAnnotationDefaults(String annotation,
Map<String,Object> defaultValues)
Registers annotation default values.
|
<T extends Annotation> |
synthesize(Class<T> annotationClass)
Synthesizes a new annotation from the metadata for the given annotation type.
|
Annotation[] |
synthesizeAll()
Synthesizes a new annotations from the metadata.
|
<T extends Annotation> |
synthesizeAnnotationsByType(Class<T> annotationClass)
Synthesizes a new annotations from the metadata for the given type.
|
Annotation[] |
synthesizeDeclared()
Synthesizes a new annotations from the metadata.
|
<T extends Annotation> |
synthesizeDeclared(Class<T> annotationClass)
Synthesizes a new annotation from the metadata for the given annotation type.
|
<T extends Annotation> |
synthesizeDeclaredAnnotationsByType(Class<T> annotationClass)
Synthesizes a new annotations from the metadata for the given type.
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
classValue, classValue, classValue, classValue, doubleValue, findAnnotation, findDeclaredAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNamesByStereotype, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDefaultValue, getDefaultValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, hasAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isFalse, isFalse, isPresent, isPresent, isTrue, isTrue, longValue
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, synthesize, synthesizeAll, synthesizeDeclared, synthesizeDeclared
protected final Map<String,Annotation> annotationMap
protected final Map<String,Annotation> declaredAnnotationMap
@Internal protected DefaultAnnotationMetadata()
@Internal public DefaultAnnotationMetadata(@Nullable Map<String,Map<CharSequence,Object>> declaredAnnotations, @Nullable Map<String,Map<CharSequence,Object>> declaredStereotypes, @Nullable Map<String,Map<CharSequence,Object>> allStereotypes, @Nullable Map<String,Map<CharSequence,Object>> allAnnotations, @Nullable Map<String,List<String>> annotationsByStereotype)
declaredAnnotations
- The directly declared annotationsdeclaredStereotypes
- The directly declared stereotypesallStereotypes
- All of the stereotypesallAnnotations
- All of the annotationsannotationsByStereotype
- The annotations by stereotypepublic <T> Optional<T> getValue(Class<? extends Annotation> annotation, String member, Class<T> requiredType)
AnnotationMetadata
getValue
in interface AnnotationMetadata
T
- The valueannotation
- The annotation classmember
- The annotation memberrequiredType
- The required typeOptional
of the valuepublic <T> Optional<T> getValue(String annotation, String member, Argument<T> requiredType)
AnnotationMetadata
getValue
in interface AnnotationMetadata
T
- The valueannotation
- The annotation classmember
- The annotation memberrequiredType
- The required typeOptional
of the valuepublic <T> Optional<T> getDefaultValue(String annotation, String member, Class<T> requiredType)
AnnotationMetadata
getDefaultValue
in interface AnnotationMetadata
T
- The required generic typeannotation
- The annotationmember
- The memberrequiredType
- The required typepublic <T extends Annotation> List<AnnotationValue<T>> getAnnotationValuesByType(Class<T> annotationType)
AnnotationMetadata
getAnnotationValuesByType
in interface AnnotationMetadata
T
- The annotation typeannotationType
- The annotation typepublic <T extends Annotation> List<AnnotationValue<T>> getDeclaredAnnotationValuesByType(Class<T> annotationType)
AnnotationMetadata
getDeclaredAnnotationValuesByType
in interface AnnotationMetadata
T
- The annotation typeannotationType
- The annotation typepublic <T extends Annotation> T[] synthesizeAnnotationsByType(Class<T> annotationClass)
AnnotationSource
synthesizeAnnotationsByType
in interface AnnotationSource
T
- The annotation generic typeannotationClass
- The annotation typepublic <T extends Annotation> T[] synthesizeDeclaredAnnotationsByType(Class<T> annotationClass)
AnnotationSource
synthesizeDeclaredAnnotationsByType
in interface AnnotationSource
T
- The annotation generic typeannotationClass
- The annotation typepublic boolean isEmpty()
AnnotationMetadata
isEmpty
in interface AnnotationMetadata
public boolean hasDeclaredAnnotation(String annotation)
AnnotationMetadata
hasDeclaredAnnotation
in interface AnnotationMetadata
annotation
- The annotationpublic boolean hasAnnotation(String annotation)
AnnotationMetadata
hasAnnotation
in interface AnnotationMetadata
annotation
- The annotationpublic boolean hasStereotype(String annotation)
AnnotationMetadata
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
hasStereotype
in interface AnnotationMetadata
annotation
- The annotationpublic boolean hasDeclaredStereotype(String annotation)
AnnotationMetadata
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
hasDeclaredStereotype
in interface AnnotationMetadata
annotation
- The annotationpublic List<String> getAnnotationNamesByStereotype(String stereotype)
AnnotationMetadata
getAnnotationNamesByStereotype
in interface AnnotationMetadata
stereotype
- The annotation namespublic Set<String> getAnnotationNames()
AnnotationMetadata
getAnnotationNames
in interface AnnotationMetadata
public Set<String> getDeclaredAnnotationNames()
AnnotationMetadata
getDeclaredAnnotationNames
in interface AnnotationMetadata
public List<String> getDeclaredAnnotationNamesByStereotype(String stereotype)
AnnotationMetadata
getDeclaredAnnotationNamesByStereotype
in interface AnnotationMetadata
stereotype
- The stereotypepublic Optional<Class<? extends Annotation>> getAnnotationType(String name)
AnnotationMetadata
getAnnotationType
in interface AnnotationMetadata
name
- The type namepublic <T extends Annotation> Optional<AnnotationValue<T>> findAnnotation(String annotation)
AnnotationSource
AnnotationValue
for the given annotation name.findAnnotation
in interface AnnotationSource
T
- The annotation typeannotation
- The annotation nameAnnotationValue
instancepublic <T extends Annotation> Optional<AnnotationValue<T>> findDeclaredAnnotation(String annotation)
AnnotationSource
findDeclaredAnnotation
in interface AnnotationSource
T
- The annotation typeannotation
- The annotation nameAnnotationValue
instancepublic <T> OptionalValues<T> getValues(String annotation, Class<T> valueType)
AnnotationMetadata
getValues
in interface AnnotationMetadata
T
- Generic typeannotation
- The annotation namevalueType
- valueTypeOptionalValues
public <T> Optional<T> getDefaultValue(String annotation, String member, Argument<T> requiredType)
AnnotationMetadata
getDefaultValue
in interface AnnotationMetadata
T
- The required generic typeannotation
- The annotationmember
- The memberrequiredType
- The required typepublic AnnotationMetadata clone()
protected final void addAnnotation(String annotation, Map<CharSequence,Object> values)
annotation
- The annotationvalues
- The valuesprotected final void addDefaultAnnotationValues(String annotation, Map<CharSequence,Object> values)
annotation
- The annotationvalues
- The values@Internal protected static boolean areAnnotationDefaultsRegistered(String annotation)
annotation
- The annotation name@Internal protected static void registerAnnotationDefaults(String annotation, Map<String,Object> defaultValues)
annotation
- The annotation namedefaultValues
- The default values@Internal protected static void registerAnnotationDefaults(AnnotationClassValue<?> annotation, Map<String,Object> defaultValues)
annotation
- The annotation namedefaultValues
- The default valuesprotected final void addRepeatable(String annotationName, AnnotationValue annotationValue)
annotationName
- The annotation nameannotationValue
- The annotation valueprotected void addRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue annotationValue)
parents
- The parent annotationsstereotype
- The annotation nameannotationValue
- The annotation valueprotected void addDeclaredRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue annotationValue)
parents
- The parent annotationsstereotype
- The annotation nameannotationValue
- The annotation valueprotected final void addDeclaredRepeatable(String annotationName, AnnotationValue annotationValue)
annotationName
- The annotation nameannotationValue
- The annotation valueprotected final void addStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values)
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The valuesprotected final void addDeclaredStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values)
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The valuesprotected void addDeclaredAnnotation(String annotation, Map<CharSequence,Object> values)
annotation
- The annotationvalues
- The values@Internal public static AnnotationMetadata mutateMember(AnnotationMetadata annotationMetadata, String annotationName, String member, Object value)
Sets a member of the given AnnotationMetadata
return a new annotation metadata instance without
mutating the existing.
WARNING: for internal use only be the framework
annotationMetadata
- The metadataannotationName
- The annotation namemember
- The membervalue
- The value@Internal public static AnnotationMetadata mutateMember(AnnotationMetadata annotationMetadata, String annotationName, Map<CharSequence,Object> members)
Sets a member of the given AnnotationMetadata
return a new annotation metadata instance without
mutating the existing.
WARNING: for internal use only be the framework
annotationMetadata
- The metadataannotationName
- The annotation namemembers
- The key/value set of members and valuespublic <T extends Annotation> T synthesize(Class<T> annotationClass)
AnnotationSource
synthesize
in interface AnnotationSource
T
- The annotation generic typeannotationClass
- The annotation classpublic <T extends Annotation> T synthesizeDeclared(Class<T> annotationClass)
AnnotationSource
This method ignores inherited annotations. (Returns null if no annotations are directly present on this element.)
synthesizeDeclared
in interface AnnotationSource
T
- The annotation generic typeannotationClass
- The annotation classpublic Annotation[] synthesizeAll()
AnnotationSource
synthesizeAll
in interface AnnotationSource
public Annotation[] synthesizeDeclared()
AnnotationSource
synthesizeDeclared
in interface AnnotationSource
protected final void addAnnotationValuesFromData(List results, Map<CharSequence,Object> values)
results
- The resultsvalues
- The valuesprotected void addValuesToResults(List<AnnotationValue> results, AnnotationValue values)
results
- The resultsvalues
- The values