Class AbstractAnnotationElement
java.lang.Object
io.micronaut.inject.ast.annotation.AbstractAnnotationElement
- All Implemented Interfaces:
AnnotatedElement
,AnnotationMetadata
,AnnotationMetadataDelegate
,AnnotationMetadataProvider
,AnnotationSource
,Described
,Named
,MutableAnnotationMetadataDelegate<Element>
,Element
- Direct Known Subclasses:
AbstractGroovyElement
,AbstractJavaElement
An abstract element.
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Field Summary
Modifier and TypeFieldDescriptionprotected final ElementAnnotationMetadataFactory
protected @Nullable AnnotationMetadata
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
Fields inherited from interface io.micronaut.inject.ast.Element
EMPTY_ELEMENT_ARRAY
Fields inherited from interface io.micronaut.inject.ast.annotation.MutableAnnotationMetadataDelegate
EMPTY
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractAnnotationElement
(ElementAnnotationMetadataFactory annotationMetadataFactory) -
Method Summary
Modifier and TypeMethodDescription<T extends Annotation>
Elementannotate
(AnnotationValue<T> annotationValue) Annotate this element with the given annotation type.<T extends Annotation>
ElementAnnotate this element with the given annotation type.<T extends Annotation>
Elementannotate
(Class<T> annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Annotate this element with the given annotation type.Annotate this element with the given annotation type.<T extends Annotation>
Elementannotate
(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Annotate this element with the given annotation type.Supplies the metadata.protected MutableAnnotationMetadataDelegate<?>
Get annotation metadata to add or remove annotations.protected ElementAnnotationMetadata
<T extends Annotation>
ElementremoveAnnotation
(Class<T> annotationType) removeAnnotation
(String annotationType) Removes an annotation of the given type from the element.<T extends Annotation>
ElementremoveAnnotationIf
(Predicate<AnnotationValue<T>> predicate) Removes all annotations that pass the given predicate.<T extends Annotation>
ElementremoveStereotype
(Class<T> annotationType) Removes a stereotype annotation of the given type from the element.removeStereotype
(String annotationType) Removes a stereotype of the given name from the element.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.annotation.AnnotatedElement
isDeclaredNonNull, isDeclaredNullable, isNonNull, isNullable
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadata
enumValuesSet, enumValuesSet, getValues, hasDeclaredStereotype, hasEvaluatedExpressions, hasStereotypeNonRepeating, isAnnotationPresent, isDeclaredAnnotationPresent
Methods inherited from interface io.micronaut.core.annotation.AnnotationMetadataDelegate
booleanValue, booleanValue, booleanValue, booleanValue, classValue, classValue, classValue, classValue, classValues, classValues, classValues, classValues, copyAnnotationMetadata, doubleValue, doubleValue, doubleValue, enumValue, enumValue, enumValue, enumValue, enumValues, enumValues, enumValues, enumValues, findAnnotation, findAnnotation, findDeclaredAnnotation, findDeclaredAnnotation, findRepeatableAnnotation, findRepeatableAnnotation, getAnnotation, getAnnotation, getAnnotationNameByStereotype, getAnnotationNameByStereotype, getAnnotationNames, getAnnotationNamesByStereotype, getAnnotationNamesByStereotype, getAnnotationType, getAnnotationType, getAnnotationTypeByStereotype, getAnnotationTypeByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationTypesByStereotype, getAnnotationValuesByName, getAnnotationValuesByStereotype, getAnnotationValuesByType, getDeclaredAnnotation, getDeclaredAnnotation, getDeclaredAnnotationNameByStereotype, getDeclaredAnnotationNames, getDeclaredAnnotationNamesByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationTypeByStereotype, getDeclaredAnnotationValuesByName, getDeclaredAnnotationValuesByType, getDeclaredMetadata, getDeclaredStereotypeAnnotationNames, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValue, getDefaultValues, getStereotypeAnnotationNames, getTargetAnnotationMetadata, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValues, getValues, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotation, hasDeclaredStereotype, hasDeclaredStereotype, hasDeclaredStereotype, hasPropertyExpressions, hasSimpleAnnotation, hasSimpleDeclaredAnnotation, hasStereotype, hasStereotype, hasStereotype, hasStereotype, intValue, intValue, intValue, isAnnotationPresent, isDeclaredAnnotationPresent, isEmpty, isFalse, isFalse, isPresent, isPresent, isRepeatableAnnotation, isRepeatableAnnotation, isTrue, isTrue, longValue, longValue, stringValue, stringValue, stringValue, stringValue, stringValues, stringValues, stringValues, stringValues, synthesize, synthesize, synthesizeAll, synthesizeAnnotationsByType, synthesizeDeclared, synthesizeDeclared, synthesizeDeclared, synthesizeDeclaredAnnotationsByType
Methods inherited from interface io.micronaut.inject.ast.Element
getDescription, getDescription, getDocumentation, getModifiers, getName, getNativeType, getSimpleName, isAbstract, isFinal, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isSynthetic, withAnnotationMetadata
-
Field Details
-
elementAnnotationMetadataFactory
-
presetAnnotationMetadata
-
-
Constructor Details
-
AbstractAnnotationElement
- Parameters:
annotationMetadataFactory
- The annotation metadata factory
-
-
Method Details
-
getAnnotationMetadata
Description copied from interface:AnnotationMetadataProvider
Supplies the metadata. Defaults toAnnotationMetadata.EMPTY_METADATA
.- Specified by:
getAnnotationMetadata
in interfaceAnnotationMetadataProvider
- Returns:
- The
AnnotationMetadata
-
getElementAnnotationMetadataFactory
-
getElementAnnotationMetadata
- Returns:
- The element's annotation metadata
-
getAnnotationMetadataToWrite
Get annotation metadata to add or remove annotations.- Returns:
- The annotation metadata to write
-
annotate
public <T extends Annotation> Element annotate(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Description copied from interface:MutableAnnotationMetadataDelegate
Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotate
in interfaceElement
- Specified by:
annotate
in interfaceMutableAnnotationMetadataDelegate<Element>
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationType
- The annotation typeconsumer
- A function that receives theAnnotationValueBuilder
- Returns:
- This element
-
removeAnnotation
Description copied from interface:MutableAnnotationMetadataDelegate
Removes an annotation of the given type from the element.If the annotation features any stereotypes these will also be removed unless there are other annotations that reference the stereotype to be removed.
In the case of repeatable annotations this method will remove all repeated annotations, effectively clearing out all declared repeated annotations of the given type.
- Specified by:
removeAnnotation
in interfaceElement
- Specified by:
removeAnnotation
in interfaceMutableAnnotationMetadataDelegate<Element>
- Parameters:
annotationType
- The annotation type- Returns:
- This element
-
removeAnnotation
- Specified by:
removeAnnotation
in interfaceElement
- Specified by:
removeAnnotation
in interfaceMutableAnnotationMetadataDelegate<Element>
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationType
- The annotation type- Returns:
- This element
- See Also:
-
removeAnnotationIf
Description copied from interface:MutableAnnotationMetadataDelegate
Removes all annotations that pass the given predicate.- Specified by:
removeAnnotationIf
in interfaceElement
- Specified by:
removeAnnotationIf
in interfaceMutableAnnotationMetadataDelegate<Element>
- Type Parameters:
T
- The annotation generic type- Parameters:
predicate
- The predicate- Returns:
- This element
-
removeStereotype
Description copied from interface:MutableAnnotationMetadataDelegate
Removes a stereotype of the given name from the element.- Specified by:
removeStereotype
in interfaceElement
- Specified by:
removeStereotype
in interfaceMutableAnnotationMetadataDelegate<Element>
- Parameters:
annotationType
- The annotation type- Returns:
- This element
-
removeStereotype
Description copied from interface:MutableAnnotationMetadataDelegate
Removes a stereotype annotation of the given type from the element.- Specified by:
removeStereotype
in interfaceElement
- Specified by:
removeStereotype
in interfaceMutableAnnotationMetadataDelegate<Element>
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationType
- The annotation type- Returns:
- This element
-
annotate
Description copied from interface:MutableAnnotationMetadataDelegate
Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotate
in interfaceElement
- Specified by:
annotate
in interfaceMutableAnnotationMetadataDelegate<Element>
- Parameters:
annotationType
- The annotation type- Returns:
- This element
-
annotate
public <T extends Annotation> Element annotate(Class<T> annotationType, Consumer<AnnotationValueBuilder<T>> consumer) Description copied from interface:MutableAnnotationMetadataDelegate
Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotate
in interfaceElement
- Specified by:
annotate
in interfaceMutableAnnotationMetadataDelegate<Element>
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationType
- The annotation typeconsumer
- A function that receives theAnnotationValueBuilder
- Returns:
- This element
-
annotate
Description copied from interface:MutableAnnotationMetadataDelegate
Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotate
in interfaceElement
- Specified by:
annotate
in interfaceMutableAnnotationMetadataDelegate<Element>
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationType
- The annotation type- Returns:
- This element
-
annotate
Description copied from interface:MutableAnnotationMetadataDelegate
Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.- Specified by:
annotate
in interfaceElement
- Specified by:
annotate
in interfaceMutableAnnotationMetadataDelegate<Element>
- Type Parameters:
T
- The annotation generic type- Parameters:
annotationValue
- The annotation type- Returns:
- This element
-