Class MutableAnnotationMetadata
- All Implemented Interfaces:
AnnotationMetadata
,AnnotationSource
,Cloneable
DefaultAnnotationMetadata
that is used only at build time.- Since:
- 2.4.0
- Author:
- graemerocher
-
Field Summary
Fields inherited from interface io.micronaut.core.annotation.AnnotationMetadata
CLASS_NAME_SUFFIX, EMPTY_METADATA, VALUE_MEMBER
Fields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.void
addAnnotationMetadata
(DefaultAnnotationMetadata annotationMetadata) Include the annotation metadata from the other instance ofDefaultAnnotationMetadata
.void
addAnnotationMetadata
(MutableAnnotationMetadata annotationMetadata) Include the annotation metadata from the other instance ofDefaultAnnotationMetadata
.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.final 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.final void
addDefaultAnnotationValues
(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
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.final 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.final void
addStereotype
(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.clone()
static void
contributeDefaults
(AnnotationMetadata target, AnnotationMetadata source) Contributes defaults to the given target.static void
contributeDefaults
(AnnotationMetadata target, AnnotationMetadataHierarchy source) Contributes defaults to the given target.static void
contributeRepeatable
(AnnotationMetadata target, AnnotationMetadata source) Contributes repeatable annotation metadata to the given target.protected String
findRepeatableAnnotationContainerInternal
(String annotation) Find annotation's repeatable container.getDefaultValues
(@NonNull String annotation) Return the default values for the given annotation name.boolean
Does the metadata contain any evaluated expressions like#{ T(java.lang.Math).random() }
.boolean
Does the metadata contain any property expressions like${foo.bar}
.static MutableAnnotationMetadata
mutateMember
(MutableAnnotationMetadata annotationMetadata, String annotationName, String member, Object value) Sets a member of the givenAnnotationMetadata
return a new annotation metadata instance without mutating the existing.static MutableAnnotationMetadata
mutateMember
(MutableAnnotationMetadata annotationMetadata, String annotationName, Map<CharSequence, Object> members) Sets a member of the givenAnnotationMetadata
return a new annotation metadata instance without mutating the existing.protected <T extends Annotation>
AnnotationValue<T>newAnnotationValue
(String annotationType, Map<CharSequence, Object> values) static MutableAnnotationMetadata
of
(AnnotationMetadata annotationMetadata) void
removeAnnotation
(String annotationType) Removes an annotation for the given annotation type.<A extends Annotation>
voidremoveAnnotationIf
(@NonNull 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>
Tsynthesize
(@NonNull Class<T> annotationClass) Synthesizes a new annotation from the metadata for the given annotation type.<T extends Annotation>
Tsynthesize
(@NonNull Class<T> annotationClass, @NonNull String sourceAnnotation) Synthesizes a new annotation for the given annotation type using the member values of the given source annotation.Synthesizes a new annotations from the metadata.Synthesizes a new annotations from the metadata.<T extends Annotation>
TsynthesizeDeclared
(@NonNull Class<T> annotationClass) Synthesizes a new annotation from the metadata for the given annotation type.<T extends Annotation>
TsynthesizeDeclared
(@NonNull Class<T> annotationClass, @NonNull String sourceAnnotation) Synthesizes a new annotation declared for the given annotation type using the member values of the given source annotation.Methods inherited from class io.micronaut.inject.annotation.DefaultAnnotationMetadata
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, cloneMap, cloneMapOfListValue, cloneMapOfMapValue, copyAnnotationMetadata, 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, registerAnnotationDefaults, registerAnnotationDefaults, registerAnnotationType, registerRepeatableAnnotations, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesizeAnnotationsByType, synthesizeDeclaredAnnotationsByType
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
booleanValue, booleanValue, classValue, classValue, classValues, classValues, doubleValue, enumValuesSet, enumValuesSet, findAnnotation, findDeclaredAnnotation, getAnnotationNameByStereotype, getAnnotationNamesByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDefaultValue, getDefaultValue, getTargetAnnotationMetadata, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, hasAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotypeNonRepeating, intValue, isAnnotationPresent, isAnnotationPresent, isDeclaredAnnotationPresent, isDeclaredAnnotationPresent, isFalse, isPresent, stringValue, stringValue, stringValues, stringValues
Methods inherited from interface io.micronaut.core.annotation.AnnotationSource
getAnnotation, getAnnotation, getDeclaredAnnotation, getDeclaredAnnotation, synthesize, synthesize, synthesizeAll, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared
-
Constructor Details
-
MutableAnnotationMetadata
public MutableAnnotationMetadata()Default constructor.
-
-
Method Details
-
of
-
hasPropertyExpressions
public boolean hasPropertyExpressions()Description copied from interface:AnnotationMetadata
Does the metadata contain any property expressions like${foo.bar}
. Note this by default returnstrue
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.- Specified by:
hasPropertyExpressions
in interfaceAnnotationMetadata
- Overrides:
hasPropertyExpressions
in classDefaultAnnotationMetadata
- Returns:
- True if property expressions are present
-
hasEvaluatedExpressions
public boolean hasEvaluatedExpressions()Description copied from interface:AnnotationMetadata
Does the metadata contain any evaluated expressions like#{ T(java.lang.Math).random() }
.- Specified by:
hasEvaluatedExpressions
in interfaceAnnotationMetadata
- Overrides:
hasEvaluatedExpressions
in classDefaultAnnotationMetadata
- Returns:
- True if evaluated expressions are present
-
clone
- Overrides:
clone
in classDefaultAnnotationMetadata
-
getDefaultValues
@NonNull public @NonNull Map<CharSequence,Object> getDefaultValues(@NonNull @NonNull String annotation) Description copied from interface:AnnotationMetadata
Return the default values for the given annotation name.- Specified by:
getDefaultValues
in interfaceAnnotationMetadata
- Overrides:
getDefaultValues
in classDefaultAnnotationMetadata
- Parameters:
annotation
- The annotation name- Returns:
- The default values
-
addAnnotation
Adds an annotation and its member values, if the annotation already exists the data will be merged with existing values replaced.- Parameters:
annotation
- The annotationvalues
- The values
-
addAnnotation
public 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.- Parameters:
annotation
- The annotationvalues
- The valuesretentionPolicy
- The retention policy
-
addDefaultAnnotationValues
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.- Parameters:
annotation
- The annotationvalues
- The values
-
addDefaultAnnotationValues
public final void addDefaultAnnotationValues(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.- Parameters:
annotation
- The annotationvalues
- The valuesretentionPolicy
- The retention policy
-
addRepeatable
Adds a repeatable annotation value. If a value already exists will be added- Parameters:
annotationName
- The annotation nameannotationValue
- The annotation value
-
addRepeatable
public void addRepeatable(String annotationName, AnnotationValue<?> annotationValue, RetentionPolicy retentionPolicy) Adds a repeatable annotation value. If a value already exists will be added- Parameters:
annotationName
- The annotation nameannotationValue
- The annotation valueretentionPolicy
- The retention policy
-
addRepeatableStereotype
public void addRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue<?> annotationValue) Adds a repeatable stereotype value. If a value already exists will be added- Parameters:
parents
- The parent annotationsstereotype
- The annotation nameannotationValue
- The annotation value
-
addDeclaredRepeatableStereotype
public void addDeclaredRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue<?> annotationValue) Adds a repeatable declared stereotype value. If a value already exists will be added- Parameters:
parents
- The parent annotationsstereotype
- The annotation nameannotationValue
- The annotation value
-
addDeclaredRepeatable
Adds a repeatable annotation value. If a value already exists will be added- Parameters:
annotationName
- The annotation nameannotationValue
- The annotation value
-
addDeclaredRepeatable
public void addDeclaredRepeatable(String annotationName, AnnotationValue<?> annotationValue, RetentionPolicy retentionPolicy) Adds a repeatable annotation value. If a value already exists will be added- Parameters:
annotationName
- The annotation nameannotationValue
- The annotation valueretentionPolicy
- The retention policy
-
addStereotype
public final 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.- Parameters:
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The values
-
addStereotype
public final void addStereotype(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.- Parameters:
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The valuesretentionPolicy
- The retention policy
-
addDeclaredStereotype
public 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.- Parameters:
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The values
-
addDeclaredStereotype
public 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.- Parameters:
parentAnnotations
- The parent annotationsstereotype
- The annotationvalues
- The valuesretentionPolicy
- The retention policy
-
addDeclaredAnnotation
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.- Parameters:
annotation
- The annotationvalues
- The values
-
addDeclaredAnnotation
public 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.- Parameters:
annotation
- The annotationvalues
- The valuesretentionPolicy
- The retention policy
-
mutateMember
@Internal public static MutableAnnotationMetadata mutateMember(MutableAnnotationMetadata 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
- Parameters:
annotationMetadata
- The metadataannotationName
- The annotation namemember
- The membervalue
- The value- Returns:
- The metadata
-
newAnnotationValue
protected <T extends Annotation> AnnotationValue<T> newAnnotationValue(String annotationType, Map<CharSequence, Object> values) - Overrides:
newAnnotationValue
in classDefaultAnnotationMetadata
-
addAnnotationMetadata
Include the annotation metadata from the other instance ofDefaultAnnotationMetadata
.- Parameters:
annotationMetadata
- The annotation metadata- Since:
- 4.0.0
-
addAnnotationMetadata
Include the annotation metadata from the other instance ofDefaultAnnotationMetadata
.- Parameters:
annotationMetadata
- The annotation metadata- Since:
- 4.0.0
-
contributeDefaults
@Internal public static void contributeDefaults(AnnotationMetadata target, AnnotationMetadata source) Contributes defaults to the given target.WARNING: for internal use only be the framework
- Parameters:
target
- The targetsource
- The source
-
contributeDefaults
@Internal public static void contributeDefaults(AnnotationMetadata target, AnnotationMetadataHierarchy source) Contributes defaults to the given target.WARNING: for internal use only be the framework
- Parameters:
target
- The targetsource
- The source- Since:
- 4.0.0
-
contributeRepeatable
@Internal public static void contributeRepeatable(AnnotationMetadata target, AnnotationMetadata source) Contributes repeatable annotation metadata to the given target.WARNING: for internal use only be the framework
- Parameters:
target
- The targetsource
- The source
-
mutateMember
@Internal public static MutableAnnotationMetadata mutateMember(MutableAnnotationMetadata 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
- Parameters:
annotationMetadata
- The metadataannotationName
- The annotation namemembers
- The key/value set of members and values- Returns:
- The metadata
-
removeAnnotationIf
public <A extends Annotation> void removeAnnotationIf(@NonNull @NonNull Predicate<AnnotationValue<A>> predicate) Removes an annotation for the given predicate.- Type Parameters:
A
- The annotation- Parameters:
predicate
- The predicate
-
removeAnnotation
Removes an annotation for the given annotation type.- Parameters:
annotationType
- The annotation type- Since:
- 3.0.0
-
removeStereotype
Removes a stereotype annotation for the given annotation type.- Parameters:
annotationType
- The annotation type- Since:
- 3.0.0
-
findRepeatableAnnotationContainerInternal
Description copied from class:DefaultAnnotationMetadata
Find annotation's repeatable container.- Overrides:
findRepeatableAnnotationContainerInternal
in classDefaultAnnotationMetadata
- Parameters:
annotation
- The annotation- Returns:
- the repeatable container or null
-
synthesize
Description copied from interface:AnnotationSource
Synthesizes a new annotation from the metadata for the given annotation type. This method works by creating a runtime proxy of the annotation interface and should be avoided in favour of direct use of the annotation metadata and only used for unique cases that require integrating third party libraries.- Specified by:
synthesize
in interfaceAnnotationSource
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationClass
- The annotation class- Returns:
- The annotation or null if it doesn't exist
-
synthesize
@Nullable public <T extends Annotation> T synthesize(@NonNull @NonNull Class<T> annotationClass, @NonNull @NonNull String sourceAnnotation) Description copied from interface:AnnotationSource
Synthesizes a new annotation for the given annotation type using the member values of the given source annotation.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 ajakarta.inject.Named
annotation.- Specified by:
synthesize
in interfaceAnnotationSource
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationClass
- The annotation classsourceAnnotation
- The source annotation that provides the member values- Returns:
- The annotation or null if it doesn't exist
-
synthesizeDeclared
@Nullable public <T extends Annotation> T synthesizeDeclared(@NonNull @NonNull Class<T> annotationClass, @NonNull @NonNull String sourceAnnotation) Description copied from interface:AnnotationSource
Synthesizes a new annotation declared for the given annotation type using the member values of the given source annotation.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 ajakarta.inject.Named
annotation.- Specified by:
synthesizeDeclared
in interfaceAnnotationSource
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationClass
- The annotation classsourceAnnotation
- The source annotation that provides the member values- Returns:
- The annotation or null if it doesn't exist
-
synthesizeDeclared
@Nullable public <T extends Annotation> T synthesizeDeclared(@NonNull @NonNull Class<T> annotationClass) Description copied from interface:AnnotationSource
Synthesizes a new annotation from the metadata for the given annotation type. This method works by creating a runtime proxy of the annotation interface and should be avoided in favour of direct use of the annotation metadata and only used for unique cases that require integrating third party libraries.This method ignores inherited annotations. (Returns null if no annotations are directly present on this element.)
- Specified by:
synthesizeDeclared
in interfaceAnnotationSource
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationClass
- The annotation class- Returns:
- The annotation or null if it doesn't exist
-
synthesizeAll
Description copied from interface:AnnotationSource
Synthesizes a new annotations from the metadata. This method works by creating a runtime proxy of the annotation interface and should be avoided in favour of direct use of the annotation metadata and only used for unique cases that require integrating third party libraries.- Specified by:
synthesizeAll
in interfaceAnnotationSource
- Returns:
- All the annotations
-
synthesizeDeclared
Description copied from interface:AnnotationSource
Synthesizes a new annotations from the metadata. This method works by creating a runtime proxy of the annotation interface and should be avoided in favour of direct use of the annotation metadata and only used for unique cases that require integrating third party libraries.- Specified by:
synthesizeDeclared
in interfaceAnnotationSource
- Returns:
- All declared annotations
-