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_MEMBERFields inherited from interface io.micronaut.core.annotation.AnnotationSource
EMPTY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAnnotation(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.voidaddAnnotation(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.voidaddAnnotationMetadata(DefaultAnnotationMetadata annotationMetadata) Include the annotation metadata from the other instance ofDefaultAnnotationMetadata.voidaddAnnotationMetadata(MutableAnnotationMetadata annotationMetadata) Include the annotation metadata from the other instance ofDefaultAnnotationMetadata.voidaddDeclaredAnnotation(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.voidaddDeclaredAnnotation(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.voidaddDeclaredRepeatable(String annotationName, AnnotationValue<?> annotationValue) Adds a repeatable annotation value.voidaddDeclaredRepeatable(String annotationName, AnnotationValue<?> annotationValue, RetentionPolicy retentionPolicy) Adds a repeatable annotation value.voidaddDeclaredRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue<?> annotationValue) Adds a repeatable declared stereotype value.voidaddDeclaredStereotype(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.voidaddDeclaredStereotype(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 voidaddDefaultAnnotationValues(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 voidaddDefaultAnnotationValues(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.voidaddRepeatable(String annotationName, AnnotationValue<?> annotationValue) Adds a repeatable annotation value.voidaddRepeatable(String annotationName, AnnotationValue<?> annotationValue, RetentionPolicy retentionPolicy) Adds a repeatable annotation value.voidaddRepeatableStereotype(List<String> parents, String stereotype, AnnotationValue<?> annotationValue) Adds a repeatable stereotype value.final voidaddStereotype(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 voidaddStereotype(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 voidcontributeDefaults(AnnotationMetadata target, AnnotationMetadata source) Contributes defaults to the given target.static voidcontributeDefaults(AnnotationMetadata target, AnnotationMetadataHierarchy source) Contributes defaults to the given target.static voidcontributeRepeatable(AnnotationMetadata target, AnnotationMetadata source) Contributes repeatable annotation metadata to the given target.protected StringfindRepeatableAnnotationContainerInternal(String annotation) Find annotation's repeatable container.getDefaultValues(@NonNull String annotation) Return the default values for the given annotation name.booleanDoes the metadata contain any evaluated expressions like#{ T(java.lang.Math).random() }.booleanDoes the metadata contain any property expressions like${foo.bar}.static MutableAnnotationMetadatamutateMember(MutableAnnotationMetadata annotationMetadata, String annotationName, String member, Object value) Sets a member of the givenAnnotationMetadatareturn a new annotation metadata instance without mutating the existing.static MutableAnnotationMetadatamutateMember(MutableAnnotationMetadata annotationMetadata, String annotationName, Map<CharSequence, Object> members) Sets a member of the givenAnnotationMetadatareturn a new annotation metadata instance without mutating the existing.protected <T extends Annotation>
AnnotationValue<T>newAnnotationValue(String annotationType, Map<CharSequence, Object> values) static MutableAnnotationMetadataof(AnnotationMetadata annotationMetadata) voidremoveAnnotation(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.voidremoveStereotype(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, synthesizeDeclaredAnnotationsByTypeMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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, stringValuesMethods 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:AnnotationMetadataDoes the metadata contain any property expressions like${foo.bar}. Note this by default returnstrueas 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:
hasPropertyExpressionsin interfaceAnnotationMetadata- Overrides:
hasPropertyExpressionsin classDefaultAnnotationMetadata- Returns:
- True if property expressions are present
-
hasEvaluatedExpressions
public boolean hasEvaluatedExpressions()Description copied from interface:AnnotationMetadataDoes the metadata contain any evaluated expressions like#{ T(java.lang.Math).random() }.- Specified by:
hasEvaluatedExpressionsin interfaceAnnotationMetadata- Overrides:
hasEvaluatedExpressionsin classDefaultAnnotationMetadata- Returns:
- True if evaluated expressions are present
-
clone
- Overrides:
clonein classDefaultAnnotationMetadata
-
getDefaultValues
@NonNull public @NonNull Map<CharSequence,Object> getDefaultValues(@NonNull @NonNull String annotation) Description copied from interface:AnnotationMetadataReturn the default values for the given annotation name.- Specified by:
getDefaultValuesin interfaceAnnotationMetadata- Overrides:
getDefaultValuesin 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
AnnotationMetadatareturn 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:
newAnnotationValuein 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
AnnotationMetadatareturn 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:DefaultAnnotationMetadataFind annotation's repeatable container.- Overrides:
findRepeatableAnnotationContainerInternalin classDefaultAnnotationMetadata- Parameters:
annotation- The annotation- Returns:
- the repeatable container or null
-
synthesize
Description copied from interface:AnnotationSourceSynthesizes 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:
synthesizein 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:AnnotationSourceSynthesizes 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.Namedannotation an be synthesized from the metadata of the ajakarta.inject.Namedannotation.- Specified by:
synthesizein 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:AnnotationSourceSynthesizes 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.Namedannotation an be synthesized from the metadata of the ajakarta.inject.Namedannotation.- Specified by:
synthesizeDeclaredin 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:AnnotationSourceSynthesizes 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:
synthesizeDeclaredin 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:AnnotationSourceSynthesizes 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:
synthesizeAllin interfaceAnnotationSource- Returns:
- All the annotations
-
synthesizeDeclared
Description copied from interface:AnnotationSourceSynthesizes 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:
synthesizeDeclaredin interfaceAnnotationSource- Returns:
- All declared annotations
-