Class PythonAnnotationMetadataBuilder
java.lang.Object
io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>
io.micronaut.python.processing.annotation.PythonAnnotationMetadataBuilder
public final class PythonAnnotationMetadataBuilder
extends AbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>
Builder for creating annotation metadata from Python decorators and elements.
This class extends Micronaut's annotation metadata builder to handle Python-specific
annotation processing, converting Python decorators to Java annotation metadata.
- Since:
- 5.2.0
- Author:
- Micronaut Team
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractAnnotationMetadataBuilder
AbstractAnnotationMetadataBuilder.CachedAnnotationMetadata -
Field Summary
Fields inherited from class AbstractAnnotationMetadataBuilder
ELEMENT_VALIDATOR -
Constructor Summary
ConstructorsConstructorDescriptionPythonAnnotationMetadataBuilder(Map<String, DecoratorDef> decorators, PythonVisitorContext visitorContext) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddError(ElementDef originatingElement, String error) Adds an error.protected voidaddWarning(ElementDef originatingElement, String warning) Adds a warning.buildDeclared(ElementDef element) Build only metadata for declared annotations.protected List<ElementDef> buildHierarchy(ElementDef element, boolean inheritTypeAnnotations, boolean declaredOnly) Build the type hierarchy for the given element.protected ElementDefgetAnnotationMember(ElementDef annotationElement, CharSequence member) Get the annotation member.protected StringgetAnnotationMemberName(ElementDef member) Read the name of an annotation member.protected Optional<ElementDef> getAnnotationMirror(String annotationName) Return a mirror for the given annotation.protected List<? extends DecoratorDef> getAnnotationsForType(ElementDef element) Obtain the annotations for the given type.protected StringgetAnnotationTypeName(DecoratorDef annotationMirror) Get the given type of the annotation.protected <K extends Annotation>
Optional<AnnotationValue<K>> getAnnotationValues(ElementDef originatingElement, ElementDef member, Class<K> annotationType) Resolve the annotations values from the given member for the given type.protected StringgetElementName(ElementDef element) Get the name for the given element.protected StringgetOriginatingClassName(ElementDef originating) protected StringgetRepeatableContainerNameForType(ElementDef annotationType) Obtain the name of the repeatable annotation if the annotation is one.protected StringgetRepeatableName(DecoratorDef annotationMirror) Obtain the name of the repeatable annotation if the annotation is one.protected RetentionPolicygetRetentionPolicy(ElementDef annotation) Gets the retention policy for the given annotation.protected ElementDefgetTypeForAnnotation(DecoratorDef annotationMirror) Get the type of the given annotation.protected VisitorContextReturns the visitor context for this implementation.protected booleanhasAnnotation(ElementDef element, Class<? extends Annotation> annotation) Checks whether an annotation is present.protected booleanhasAnnotation(ElementDef element, String annotation) Checks whether an annotation is present.protected booleanhasAnnotations(ElementDef element) Checks whether any annotations are present on the given element.protected booleanisValidationRequired(ElementDef member) Return whether the given member requires validation.List<AnnotationValue<?>> mapAnnotation(DecoratorDef decorator) protected voidpostProcess(MutableAnnotationMetadata annotationMetadata, ElementDef element) protected Map<? extends ElementDef, ?> readAnnotationDefaultValues(String annotationName, ElementDef annotationType) Read the raw default annotation values from the given annotation.protected Map<? extends ElementDef, ?> readAnnotationRawValues(DecoratorDef annotationMirror) Read the raw annotation values from the given annotation.protected voidreadAnnotationRawValues(ElementDef originatingElement, String annotationName, ElementDef member, String memberName, Object annotationValue, Map<CharSequence, Object> annotationValues) Read the given member and value, applying conversions if necessary, and place the data in the given map.protected ObjectreadAnnotationValue(ElementDef originatingElement, ElementDef member, String annotationName, String memberName, Object annotationValue) Read the given member and value, applying conversions if necessary, and place the data in the given map.Methods inherited from class AbstractAnnotationMetadataBuilder
annotate, buildAnnotation, buildEvaluatedExpressionReference, buildInternal, clearCaches, clearMutated, clearMutated, copyToRuntime, findRepeatableContainerNameForType, getAnnotationDefaultValues, getAnnotationMappers, getAnnotationTransformers, getCachedAnnotationDefaults, getElementValidator, getMappedAnnotationNames, getMappedAnnotationPackages, getRetentionPolicy, isEvaluatedExpression, isExcludedAnnotation, isRepeatableAnnotationContainer, lookupOrBuild, lookupOrBuildForField, lookupOrBuildForMethod, lookupOrBuildForParameter, lookupOrBuildForType, readAnnotationDefaultValues, readAnnotationRawValues, readNestedAnnotationValue, readNestedAnnotationValue, removeAnnotation, removeAnnotationIf, removeStereotype, validateAnnotationValue
-
Constructor Details
-
PythonAnnotationMetadataBuilder
public PythonAnnotationMetadataBuilder(Map<String, DecoratorDef> decorators, PythonVisitorContext visitorContext)
-
-
Method Details
-
mapAnnotation
-
buildDeclared
Description copied from class:AbstractAnnotationMetadataBuilderBuild only metadata for declared annotations.- Overrides:
buildDeclaredin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
element- The element- Returns:
- The
AnnotationMetadata
-
getTypeForAnnotation
Description copied from class:AbstractAnnotationMetadataBuilderGet the type of the given annotation.- Specified by:
getTypeForAnnotationin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationMirror- The annotation- Returns:
- The type
-
getAnnotationTypeName
Description copied from class:AbstractAnnotationMetadataBuilderGet the given type of the annotation.- Specified by:
getAnnotationTypeNamein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationMirror- The annotation- Returns:
- The type
-
buildHierarchy
protected List<ElementDef> buildHierarchy(ElementDef element, boolean inheritTypeAnnotations, boolean declaredOnly) Description copied from class:AbstractAnnotationMetadataBuilderBuild the type hierarchy for the given element.- Specified by:
buildHierarchyin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
element- The elementinheritTypeAnnotations- Whether to inherit type annotationsdeclaredOnly- Whether to only include declared annotations- Returns:
- The type hierarchy
-
getAnnotationsForType
Description copied from class:AbstractAnnotationMetadataBuilderObtain the annotations for the given type. This method is also responsible for unwrapping repeatable annotations.For example,
@Parent(value = {@Child, @Child})should result in the two child annotations being returned from this method instead of the parent annotation.- Specified by:
getAnnotationsForTypein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
element- The type element- Returns:
- The annotations
-
hasAnnotation
Description copied from class:AbstractAnnotationMetadataBuilderChecks whether an annotation is present.- Specified by:
hasAnnotationin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
element- The elementannotation- The annotation type name- Returns:
- True if the annotation is present
-
hasAnnotation
Description copied from class:AbstractAnnotationMetadataBuilderChecks whether an annotation is present.- Specified by:
hasAnnotationin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
element- The elementannotation- The annotation type- Returns:
- True if the annotation is present
-
hasAnnotations
Description copied from class:AbstractAnnotationMetadataBuilderChecks whether any annotations are present on the given element.- Specified by:
hasAnnotationsin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
element- The element- Returns:
- True if the annotation is present
-
postProcess
- Overrides:
postProcessin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>
-
readAnnotationValue
protected Object readAnnotationValue(ElementDef originatingElement, ElementDef member, String annotationName, String memberName, Object annotationValue) Description copied from class:AbstractAnnotationMetadataBuilderRead the given member and value, applying conversions if necessary, and place the data in the given map.- Specified by:
readAnnotationValuein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
originatingElement- The originating elementmember- The memberannotationName- The annotation namememberName- The member nameannotationValue- The value- Returns:
- The object
-
readAnnotationRawValues
protected void readAnnotationRawValues(ElementDef originatingElement, String annotationName, ElementDef member, String memberName, Object annotationValue, Map<CharSequence, Object> annotationValues) Description copied from class:AbstractAnnotationMetadataBuilderRead the given member and value, applying conversions if necessary, and place the data in the given map.- Specified by:
readAnnotationRawValuesin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
originatingElement- The originating elementannotationName- The annotation namemember- The member being read frommemberName- The memberannotationValue- The valueannotationValues- The values to populate
-
isValidationRequired
Description copied from class:AbstractAnnotationMetadataBuilderReturn whether the given member requires validation.- Specified by:
isValidationRequiredin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
member- The member- Returns:
- True if it is
-
addError
Description copied from class:AbstractAnnotationMetadataBuilderAdds an error.- Specified by:
addErrorin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
originatingElement- The originating elementerror- The error
-
addWarning
Description copied from class:AbstractAnnotationMetadataBuilderAdds a warning.- Specified by:
addWarningin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
originatingElement- The originating elementwarning- The warning
-
readAnnotationDefaultValues
protected Map<? extends ElementDef, ?> readAnnotationDefaultValues(String annotationName, ElementDef annotationType) Description copied from class:AbstractAnnotationMetadataBuilderRead the raw default annotation values from the given annotation.- Specified by:
readAnnotationDefaultValuesin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationName- annotation nameannotationType- the type- Returns:
- The values
-
readAnnotationRawValues
Description copied from class:AbstractAnnotationMetadataBuilderRead the raw annotation values from the given annotation.- Specified by:
readAnnotationRawValuesin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationMirror- The annotation- Returns:
- The values
-
getAnnotationValues
protected <K extends Annotation> Optional<AnnotationValue<K>> getAnnotationValues(ElementDef originatingElement, ElementDef member, Class<K> annotationType) Description copied from class:AbstractAnnotationMetadataBuilderResolve the annotations values from the given member for the given type.- Specified by:
getAnnotationValuesin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Type Parameters:
K- The annotation type- Parameters:
originatingElement- The originating elementmember- The memberannotationType- The type- Returns:
- The values
-
getElementName
Description copied from class:AbstractAnnotationMetadataBuilderGet the name for the given element.- Specified by:
getElementNamein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
element- The element- Returns:
- The name
-
getAnnotationMemberName
Description copied from class:AbstractAnnotationMetadataBuilderRead the name of an annotation member.- Specified by:
getAnnotationMemberNamein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
member- The member- Returns:
- The name
-
getRepeatableName
Description copied from class:AbstractAnnotationMetadataBuilderObtain the name of the repeatable annotation if the annotation is one.- Specified by:
getRepeatableNamein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationMirror- The annotation mirror- Returns:
- Return the name or null
-
getRepeatableContainerNameForType
Description copied from class:AbstractAnnotationMetadataBuilderObtain the name of the repeatable annotation if the annotation is one.- Specified by:
getRepeatableContainerNameForTypein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationType- The annotation mirror- Returns:
- Return the name or null
-
getAnnotationMirror
Description copied from class:AbstractAnnotationMetadataBuilderReturn a mirror for the given annotation.- Specified by:
getAnnotationMirrorin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationName- The annotation name- Returns:
- An optional mirror
-
getOriginatingClassName
- Specified by:
getOriginatingClassNamein classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>
-
getAnnotationMember
Description copied from class:AbstractAnnotationMetadataBuilderGet the annotation member.- Specified by:
getAnnotationMemberin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotationElement- The annotation elementmember- The member- Returns:
- The annotation member element
-
getVisitorContext
Description copied from class:AbstractAnnotationMetadataBuilderReturns the visitor context for this implementation.- Specified by:
getVisitorContextin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Returns:
- The visitor context
-
getRetentionPolicy
Description copied from class:AbstractAnnotationMetadataBuilderGets the retention policy for the given annotation.- Specified by:
getRetentionPolicyin classAbstractAnnotationMetadataBuilder<ElementDef, DecoratorDef>- Parameters:
annotation- The annotation- Returns:
- The retention policy
-