public class MutableAnnotationMetadata extends DefaultAnnotationMetadata
DefaultAnnotationMetadata
that is used only at build time.Modifier and Type | Field and Description |
---|---|
protected Map<String,Annotation> |
annotationMap |
protected Map<String,Annotation> |
declaredAnnotationMap |
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
EMPTY
Constructor and Description |
---|
MutableAnnotationMetadata()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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.
|
void |
addAnnotation(String annotation,
Map<CharSequence,Object> values,
RetentionPolicy retentionPolicy)
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.
|
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.
|
void |
addDeclaredAnnotation(String annotation,
Map<CharSequence,Object> values,
RetentionPolicy retentionPolicy)
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.
|
void |
addDeclaredRepeatable(String annotationName,
AnnotationValue annotationValue)
Adds a repeatable annotation value.
|
void |
addDeclaredRepeatable(String annotationName,
AnnotationValue annotationValue,
RetentionPolicy retentionPolicy)
Adds a repeatable annotation value.
|
void |
addDeclaredRepeatableStereotype(List<String> parents,
String stereotype,
AnnotationValue annotationValue)
Adds a repeatable declared stereotype value.
|
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.
|
void |
addDeclaredStereotype(List<String> parentAnnotations,
String stereotype,
Map<CharSequence,Object> values,
RetentionPolicy retentionPolicy)
Adds a stereotype and its member values, if the annotation already exists the data will be merged with existing
values replaced.
|
void |
addRepeatable(String annotationName,
AnnotationValue annotationValue)
Adds a repeatable annotation value.
|
void |
addRepeatable(String annotationName,
AnnotationValue annotationValue,
RetentionPolicy retentionPolicy)
Adds a repeatable annotation value.
|
void |
addRepeatableStereotype(List<String> parents,
String stereotype,
AnnotationValue annotationValue)
Adds a repeatable stereotype value.
|
protected void |
addValuesToResults(List<AnnotationValue> results,
AnnotationValue values)
Adds a values instance to the results.
|
MutableAnnotationMetadata |
clone() |
Map<String,Object> |
getDefaultValues(String annotation)
Return the default values for the given annotation name.
|
boolean |
hasPropertyExpressions()
Does the metadata contain any property expressions like
${foo.bar} . |
void |
removeAnnotation(String annotationType)
Removes an annotation for the given annotation type.
|
<A extends Annotation> |
removeAnnotationIf(Predicate<AnnotationValue<A>> predicate)
Removes an annotation for the given predicate.
|
void |
removeStereotype(String annotationType)
Removes a stereotype annotation for the given annotation type.
|
<T extends Annotation> |
synthesize(Class<T> annotationClass)
Synthesizes a new annotation from the metadata for the given annotation type.
|
<T extends Annotation> |
synthesize(Class<T> annotationClass,
String sourceAnnotation)
Synthesizes a new annotation for the given annotation type using the member values of the given source annotation.
|
Annotation[] |
synthesizeAll()
Synthesizes a new annotations from the metadata.
|
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> |
synthesizeDeclared(Class<T> annotationClass,
String sourceAnnotation)
Synthesizes a new annotation declared for the given annotation type using the member values of the given source annotation.
|
addDefaultAnnotationValues, addStereotype, addStereotype, areAnnotationDefaultsRegistered, booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, cloneMap, cloneMapOfListValue, cloneMapOfMapValue, contributeDefaults, contributeRepeatable, contributeRepeatable, doubleValue, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, enumValues, enumValues, findAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getStereotypeAnnotationNames, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasStereotype, intValue, intValue, intValue, intValue, isEmpty, isFalse, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, isTrue, isTrue, longValue, longValue, longValue, longValue, mutateMember, mutateMember, registerAnnotationDefaults, registerAnnotationDefaults, registerAnnotationType, registerRepeatableAnnotations, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesizeAnnotationsByType, synthesizeDeclaredAnnotationsByType
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
booleanValue, booleanValue, classValue, classValue, classValues, classValues, doubleValue, findAnnotation, findDeclaredAnnotation, getAnnotationNameByStereotype, getAnnotationNamesByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDefaultValue, getDefaultValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, hasAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, intValue, isAnnotationPresent, isAnnotationPresent, isDeclaredAnnotationPresent, isDeclaredAnnotationPresent, isFalse, isPresent, stringValue, stringValue, stringValues, stringValues
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, synthesize, synthesize, synthesizeAll, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared
protected final Map<String,Annotation> annotationMap
protected final Map<String,Annotation> declaredAnnotationMap
public MutableAnnotationMetadata()
public boolean hasPropertyExpressions()
AnnotationMetadata
${foo.bar}
. Note
this by default returns true
as previous versions of Micronaut must assume metadata
is present. The compilation time this is computed in order to decide whether to instrument
annotation metadata with environment specific logic.hasPropertyExpressions
in interface AnnotationMetadata
hasPropertyExpressions
in class DefaultAnnotationMetadata
public MutableAnnotationMetadata clone()
clone
in class DefaultAnnotationMetadata
@NonNull public Map<String,Object> getDefaultValues(@NonNull String annotation)
AnnotationMetadata
getDefaultValues
in interface AnnotationMetadata
getDefaultValues
in class DefaultAnnotationMetadata
annotation
- The annotation namepublic <A extends Annotation> void removeAnnotationIf(@NonNull Predicate<AnnotationValue<A>> predicate)
DefaultAnnotationMetadata
removeAnnotationIf
in class DefaultAnnotationMetadata
A
- The annotationpredicate
- The predicatepublic void removeAnnotation(String annotationType)
DefaultAnnotationMetadata
removeAnnotation
in class DefaultAnnotationMetadata
annotationType
- The annotation typepublic void removeStereotype(String annotationType)
DefaultAnnotationMetadata
removeStereotype
in class DefaultAnnotationMetadata
annotationType
- The annotation typepublic void addAnnotation(String annotation, Map<CharSequence,Object> values)
DefaultAnnotationMetadata
addAnnotation
in class DefaultAnnotationMetadata
annotation
- The annotationvalues
- The valuespublic void addAnnotation(String annotation, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
DefaultAnnotationMetadata
addAnnotation
in class DefaultAnnotationMetadata
annotation
- The annotationvalues
- The valuesretentionPolicy
- The retention policypublic void addRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue annotationValue)
DefaultAnnotationMetadata
addRepeatableStereotype
in class DefaultAnnotationMetadata
parents
- The parent annotationsstereotype
- The annotation nameannotationValue
- The annotation valuepublic void addDeclaredRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue annotationValue)
DefaultAnnotationMetadata
addDeclaredRepeatableStereotype
in class DefaultAnnotationMetadata
parents
- The parent annotationsstereotype
- The annotation nameannotationValue
- The annotation valuepublic void addDeclaredAnnotation(String annotation, Map<CharSequence,Object> values)
DefaultAnnotationMetadata
addDeclaredAnnotation
in class DefaultAnnotationMetadata
annotation
- The annotationvalues
- The valuespublic void addDeclaredAnnotation(String annotation, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
DefaultAnnotationMetadata
addDeclaredAnnotation
in class DefaultAnnotationMetadata
annotation
- The annotationvalues
- The valuesretentionPolicy
- The retention policypublic void addRepeatable(String annotationName, AnnotationValue annotationValue)
DefaultAnnotationMetadata
addRepeatable
in class DefaultAnnotationMetadata
annotationName
- The annotation nameannotationValue
- The annotation valuepublic void addRepeatable(String annotationName, AnnotationValue annotationValue, RetentionPolicy retentionPolicy)
DefaultAnnotationMetadata
addRepeatable
in class DefaultAnnotationMetadata
annotationName
- The annotation nameannotationValue
- The annotation valueretentionPolicy
- The retention policypublic void addDeclaredRepeatable(String annotationName, AnnotationValue annotationValue)
DefaultAnnotationMetadata
addDeclaredRepeatable
in class DefaultAnnotationMetadata
annotationName
- The annotation nameannotationValue
- The annotation valuepublic void addDeclaredRepeatable(String annotationName, AnnotationValue annotationValue, RetentionPolicy retentionPolicy)
DefaultAnnotationMetadata
addDeclaredRepeatable
in class DefaultAnnotationMetadata
annotationName
- The annotation nameannotationValue
- The annotation valueretentionPolicy
- The retention policypublic void addDeclaredStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values)
DefaultAnnotationMetadata
addDeclaredStereotype
in class DefaultAnnotationMetadata
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The valuespublic void addDeclaredStereotype(List<String> parentAnnotations, String stereotype, Map<CharSequence,Object> values, RetentionPolicy retentionPolicy)
DefaultAnnotationMetadata
addDeclaredStereotype
in class DefaultAnnotationMetadata
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The valuesretentionPolicy
- The retention policy@Nullable public <T extends Annotation> T synthesize(@NonNull Class<T> annotationClass)
AnnotationSource
synthesize
in interface AnnotationSource
T
- The annotation generic typeannotationClass
- The annotation class@Nullable public <T extends Annotation> T synthesize(@NonNull Class<T> annotationClass, @NonNull String sourceAnnotation)
AnnotationSource
This method allows supporting synthesizing annotations that have been renamed, for example a jakarta.inject.Named
annotation an be synthesized from the metadata of the a javax.inject.Named
annotation.
synthesize
in interface AnnotationSource
T
- The annotation generic typeannotationClass
- The annotation classsourceAnnotation
- The source annotation that provides the member values@Nullable public <T extends Annotation> T synthesizeDeclared(@NonNull Class<T> annotationClass, @NonNull String sourceAnnotation)
AnnotationSource
This method allows supporting synthesizing annotations that have been renamed, for example a jakarta.inject.Named
annotation an be synthesized from the metadata of the a javax.inject.Named
annotation.
synthesizeDeclared
in interface AnnotationSource
T
- The annotation generic typeannotationClass
- The annotation classsourceAnnotation
- The source annotation that provides the member values@Nullable public <T extends Annotation> T synthesizeDeclared(@NonNull 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 class@NonNull public Annotation[] synthesizeAll()
AnnotationSource
synthesizeAll
in interface AnnotationSource
@NonNull 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