Class JavaAnnotationMetadataBuilder
java.lang.Object
io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
io.micronaut.annotation.processing.JavaAnnotationMetadataBuilder
public class JavaAnnotationMetadataBuilder
extends AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
A
AnnotationMetadata for builder for Java to be used at compile time.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested classes/interfaces inherited from class io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder
AbstractAnnotationMetadataBuilder.CachedAnnotationMetadata -
Field Summary
Fields inherited from class io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder
ELEMENT_VALIDATOR -
Constructor Summary
ConstructorsConstructorDescriptionJavaAnnotationMetadataBuilder(Elements elements, Messager messager, AnnotationUtils annotationUtils, ModelUtils modelUtils) Deprecated, for removal: This API element is subject to removal in a future version.Not neededJavaAnnotationMetadataBuilder(Elements elements, Messager messager, ModelUtils modelUtils, JavaNativeElementsHelper nativeElementsHelper, JavaVisitorContext visitorContext) Default constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds an error.protected voidaddWarning(@NonNull Element originatingElement, @NonNull String warning) Adds a warning.buildHierarchy(Element element, boolean inheritTypeAnnotations, boolean declaredOnly) Build the type hierarchy for the given element.static voidClears any caches from the last compilation round.getAnnotationMember(Element annotationElement, CharSequence member) Get the annotation member.protected StringgetAnnotationMemberName(Element member) Read the name of an annotation member.getAnnotationMirror(String annotationName) Return a mirror for the given annotation.protected List<? extends AnnotationMirror>getAnnotationsForType(Element element) Obtain the annotations for the given type.protected StringgetAnnotationTypeName(AnnotationMirror annotationMirror) Get the given type of the annotation.protected <K extends Annotation>
Optional<AnnotationValue<K>>getAnnotationValues(Element originatingElement, Element member, Class<K> annotationType) Resolve the annotations values from the given member for the given type.protected StringgetElementName(Element element) Get the name for the given element.protected StringgetOriginatingClassName(@NonNull Element orginatingElement) getRepeatableContainerNameForType(Element annotationType) Obtain the name of the repeatable annotation if the annotation is one.getRepeatableName(AnnotationMirror annotationMirror) Obtain the name of the repeatable annotation if the annotation is one.protected @NonNull RetentionPolicygetRetentionPolicy(@NonNull Element annotation) Gets the retention policy for the given annotation.protected ElementgetTypeForAnnotation(AnnotationMirror annotationMirror) Get the type of the given annotation.protected VisitorContextReturns the visitor context for this implementation.booleanhasAnnotation(Element element, Class<? extends Annotation> ann) Checks if a method has an annotation.booleanhasAnnotation(Element element, String ann) Checks if a method has an annotation.static booleanhasAnnotation(ExecutableElement method, Class<? extends Annotation> ann) Checks if a method has an annotation.protected booleanhasAnnotations(Element element) Checks whether any annotations are present on the given element.protected booleanisExcludedAnnotation(@NonNull Element element, @NonNull String annotationName) Is the given annotation excluded for the specified element.protected booleanisValidationRequired(Element member) Return whether the given member requires validation.readAnnotationDefaultValues(String annotationTypeName, Element element) Read the raw default annotation values from the given annotation.readAnnotationRawValues(AnnotationMirror annotationMirror) Read the raw annotation values from the given annotation.protected voidreadAnnotationRawValues(Element originatingElement, String annotationName, Element 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 voidreadAnnotationRawValues(Element originatingElement, String annotationName, Element member, String memberName, Object annotationValue, Map<CharSequence, Object> annotationValues, Map<String, Map<CharSequence, Object>> resolvedDefaults) Read the given member and value, applying conversions if necessary, and place the data in the given map.protected ObjectreadAnnotationValue(Element originatingElement, Element 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 io.micronaut.inject.annotation.AbstractAnnotationMetadataBuilder
annotate, buildDeclared, buildEvaluatedExpressionReference, clearMutated, clearMutated, copyToRuntime, findRepeatableContainerNameForType, getAnnotationMappers, getAnnotationTransformers, getCachedAnnotationDefaults, getElementValidator, getMappedAnnotationNames, getMappedAnnotationPackages, getRetentionPolicy, isEvaluatedExpression, isRepeatableAnnotationContainer, lookupOrBuild, lookupOrBuildForField, lookupOrBuildForMethod, lookupOrBuildForParameter, lookupOrBuildForType, postProcess, readNestedAnnotationValue, readNestedAnnotationValue, removeAnnotation, removeAnnotationIf, removeStereotype, validateAnnotationValue
-
Constructor Details
-
JavaAnnotationMetadataBuilder
@Deprecated(forRemoval=true, since="4.3.0") public JavaAnnotationMetadataBuilder(Elements elements, Messager messager, AnnotationUtils annotationUtils, ModelUtils modelUtils) Deprecated, for removal: This API element is subject to removal in a future version.Not neededDefault constructor.- Parameters:
elements- The elementUtilsmessager- The messagerannotationUtils- The annotation utilsmodelUtils- The model utils
-
JavaAnnotationMetadataBuilder
public JavaAnnotationMetadataBuilder(Elements elements, Messager messager, ModelUtils modelUtils, JavaNativeElementsHelper nativeElementsHelper, JavaVisitorContext visitorContext) Default constructor.- Parameters:
elements- The elementUtilsmessager- The messagermodelUtils- The model utilsnativeElementsHelper- The native elements helpervisitorContext- The visitor context
-
-
Method Details
-
addError
protected void addError(@NonNull @NonNull Element originatingElement, @NonNull @NonNull String error) Description copied from class:AbstractAnnotationMetadataBuilderAdds an error.- Specified by:
addErrorin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
originatingElement- The originating elementerror- The error
-
addWarning
protected void addWarning(@NonNull @NonNull Element originatingElement, @NonNull @NonNull String warning) Description copied from class:AbstractAnnotationMetadataBuilderAdds a warning.- Specified by:
addWarningin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
originatingElement- The originating elementwarning- The warning
-
getAnnotationMemberName
Description copied from class:AbstractAnnotationMetadataBuilderRead the name of an annotation member.- Specified by:
getAnnotationMemberNamein classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - 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<Element,AnnotationMirror> - 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<Element,AnnotationMirror> - 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<Element,AnnotationMirror> - Parameters:
annotationName- The annotation name- Returns:
- An optional mirror
-
getVisitorContext
Description copied from class:AbstractAnnotationMetadataBuilderReturns the visitor context for this implementation.- Specified by:
getVisitorContextin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Returns:
- The visitor context
-
getRetentionPolicy
@NonNull protected @NonNull RetentionPolicy getRetentionPolicy(@NonNull @NonNull Element annotation) Description copied from class:AbstractAnnotationMetadataBuilderGets the retention policy for the given annotation.- Specified by:
getRetentionPolicyin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
annotation- The annotation- Returns:
- The retention policy
-
getTypeForAnnotation
Description copied from class:AbstractAnnotationMetadataBuilderGet the type of the given annotation.- Specified by:
getTypeForAnnotationin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
annotationMirror- The annotation- Returns:
- The type
-
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<Element,AnnotationMirror> - Parameters:
element- The type element- Returns:
- The annotations
-
isExcludedAnnotation
protected boolean isExcludedAnnotation(@NonNull @NonNull Element element, @NonNull @NonNull String annotationName) Description copied from class:AbstractAnnotationMetadataBuilderIs the given annotation excluded for the specified element.- Overrides:
isExcludedAnnotationin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
element- The elementannotationName- The annotation name- Returns:
- True if it is excluded
-
buildHierarchy
protected List<Element> buildHierarchy(Element element, boolean inheritTypeAnnotations, boolean declaredOnly) Description copied from class:AbstractAnnotationMetadataBuilderBuild the type hierarchy for the given element.- Specified by:
buildHierarchyin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
element- The elementinheritTypeAnnotations- Whether to inherit type annotationsdeclaredOnly- Whether to only include declared annotations- Returns:
- The type hierarchy
-
readAnnotationRawValues
Description copied from class:AbstractAnnotationMetadataBuilderRead the raw annotation values from the given annotation.- Specified by:
readAnnotationRawValuesin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
annotationMirror- The annotation- Returns:
- The values
-
getAnnotationMember
@Nullable protected @Nullable Element getAnnotationMember(Element annotationElement, CharSequence member) Description copied from class:AbstractAnnotationMetadataBuilderGet the annotation member.- Specified by:
getAnnotationMemberin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
annotationElement- The annotation elementmember- The member- Returns:
- The annotation member element
-
getOriginatingClassName
- Specified by:
getOriginatingClassNamein classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
-
getAnnotationValues
protected <K extends Annotation> Optional<AnnotationValue<K>> getAnnotationValues(Element originatingElement, Element member, Class<K> annotationType) Description copied from class:AbstractAnnotationMetadataBuilderResolve the annotations values from the given member for the given type.- Specified by:
getAnnotationValuesin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Type Parameters:
K- The annotation type- Parameters:
originatingElement- The originating elementmember- The memberannotationType- The type- Returns:
- The values
-
readAnnotationRawValues
protected void readAnnotationRawValues(Element originatingElement, String annotationName, Element 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<Element,AnnotationMirror> - Parameters:
originatingElement- The originating elementannotationName- The annotation namemember- The member being read frommemberName- The memberannotationValue- The valueannotationValues- The values to populate
-
readAnnotationRawValues
protected void readAnnotationRawValues(Element originatingElement, String annotationName, Element member, String memberName, Object annotationValue, Map<CharSequence, Object> annotationValues, Map<String, Map<CharSequence, Object>> resolvedDefaults) Description copied from class:AbstractAnnotationMetadataBuilderRead the given member and value, applying conversions if necessary, and place the data in the given map.- Overrides:
readAnnotationRawValuesin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
originatingElement- The originating elementannotationName- The annotation namemember- The member being read frommemberName- The memberannotationValue- The valueannotationValues- The values to populateresolvedDefaults- The resolved defaults
-
isValidationRequired
Description copied from class:AbstractAnnotationMetadataBuilderReturn whether the given member requires validation.- Specified by:
isValidationRequiredin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
member- The member- Returns:
- True if it is
-
readAnnotationValue
protected Object readAnnotationValue(Element originatingElement, Element 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<Element,AnnotationMirror> - Parameters:
originatingElement- The originating elementmember- The memberannotationName- The annotation namememberName- The member nameannotationValue- The value- Returns:
- The object
-
readAnnotationDefaultValues
protected Map<? extends Element,?> readAnnotationDefaultValues(String annotationTypeName, Element element) Description copied from class:AbstractAnnotationMetadataBuilderRead the raw default annotation values from the given annotation.- Specified by:
readAnnotationDefaultValuesin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
annotationTypeName- annotation nameelement- the type- Returns:
- The values
-
getAnnotationTypeName
Description copied from class:AbstractAnnotationMetadataBuilderGet the given type of the annotation.- Specified by:
getAnnotationTypeNamein classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
annotationMirror- The annotation- Returns:
- The type
-
getElementName
Description copied from class:AbstractAnnotationMetadataBuilderGet the name for the given element.- Specified by:
getElementNamein classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
element- The element- Returns:
- The name
-
hasAnnotation
Checks if a method has an annotation.- Specified by:
hasAnnotationin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
element- The methodann- The annotation to look for- Returns:
- Whether if the method has the annotation
-
hasAnnotation
Checks if a method has an annotation.- Specified by:
hasAnnotationin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
element- The methodann- The annotation to look for- Returns:
- Whether if the method has the annotation
-
hasAnnotations
Description copied from class:AbstractAnnotationMetadataBuilderChecks whether any annotations are present on the given element.- Specified by:
hasAnnotationsin classAbstractAnnotationMetadataBuilder<Element,AnnotationMirror> - Parameters:
element- The element- Returns:
- True if the annotation is present
-
clearCaches
public static void clearCaches()Clears any caches from the last compilation round. -
hasAnnotation
Checks if a method has an annotation.- Parameters:
method- The methodann- The annotation to look for- Returns:
- Whether if the method has the annotation
-