Class AnnotationUtils
- java.lang.Object
-
- io.micronaut.annotation.processing.AnnotationUtils
-
@Internal public class AnnotationUtils extends java.lang.ObjectUtility methods for annotations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAnnotationUtils(javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.util.Elements elementUtils, javax.annotation.processing.Messager messager, javax.lang.model.util.Types types, ModelUtils modelUtils, GenericUtils genericUtils, javax.annotation.processing.Filer filer)Default constructor.protectedAnnotationUtils(javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.util.Elements elementUtils, javax.annotation.processing.Messager messager, javax.lang.model.util.Types types, ModelUtils modelUtils, GenericUtils genericUtils, javax.annotation.processing.Filer filer, io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> visitorAttributes)Default constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description io.micronaut.core.annotation.AnnotationMetadatagetAnnotationMetadata(java.util.List<javax.lang.model.element.Element> parents, javax.lang.model.element.Element element)Get the annotation metadata for the given element and the given parents.io.micronaut.core.annotation.AnnotationMetadatagetAnnotationMetadata(javax.lang.model.element.Element element)Get the annotation metadata for the given element.io.micronaut.core.annotation.AnnotationMetadatagetAnnotationMetadata(javax.lang.model.element.Element parent, javax.lang.model.element.Element element)Get the annotation metadata for the given element and the given parent.io.micronaut.core.annotation.AnnotationMetadatagetDeclaredAnnotationMetadata(javax.lang.model.element.Element element)Get the declared annotation metadata for the given element.io.micronaut.inject.annotation.AnnotatedElementValidatorgetElementValidator()TheAnnotatedElementValidatorinstance.protected booleanhasStereotype(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> stereotype)Return whether the given element is annotated with the given annotation stereotype.protected booleanhasStereotype(javax.lang.model.element.Element element, java.lang.String... stereotypes)Return whether the given element is annotated with the given annotation stereotypes.protected booleanhasStereotype(javax.lang.model.element.Element element, java.util.List<java.lang.String> stereotypes)Return whether the given element is annotated with any of the given annotation stereotypes.static voidinvalidateMetadata(javax.lang.model.element.Element element)Invalidates any cached metadata.booleanisAnnotated(java.lang.String declaringType, javax.lang.model.element.ExecutableElement method)Check whether the method is annotated.JavaAnnotationMetadataBuildernewAnnotationBuilder()Creates a new annotation builder.JavaVisitorContextnewVisitorContext()Creates a newJavaVisitorContext.
-
-
-
Constructor Detail
-
AnnotationUtils
protected AnnotationUtils(javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.util.Elements elementUtils, javax.annotation.processing.Messager messager, javax.lang.model.util.Types types, ModelUtils modelUtils, GenericUtils genericUtils, javax.annotation.processing.Filer filer, io.micronaut.core.convert.value.MutableConvertibleValues<java.lang.Object> visitorAttributes)Default constructor.- Parameters:
processingEnv- The processing envelementUtils- The elementsmessager- The messagertypes- The typesmodelUtils- The model utilsgenericUtils- The generic utilsfiler- The filervisitorAttributes- The visitor attributes
-
AnnotationUtils
protected AnnotationUtils(javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.util.Elements elementUtils, javax.annotation.processing.Messager messager, javax.lang.model.util.Types types, ModelUtils modelUtils, GenericUtils genericUtils, javax.annotation.processing.Filer filer)Default constructor.- Parameters:
processingEnv- The processing envelementUtils- The elementsmessager- The messagertypes- The typesmodelUtils- The model utilsgenericUtils- The generic utilsfiler- The filer
-
-
Method Detail
-
getElementValidator
@Nullable public io.micronaut.inject.annotation.AnnotatedElementValidator getElementValidator()
TheAnnotatedElementValidatorinstance. Can be null.- Returns:
- The validator instance
-
hasStereotype
protected boolean hasStereotype(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> stereotype)Return whether the given element is annotated with the given annotation stereotype.- Parameters:
element- The elementstereotype- The stereotype- Returns:
- True if it is
-
hasStereotype
protected boolean hasStereotype(javax.lang.model.element.Element element, java.lang.String... stereotypes)Return whether the given element is annotated with the given annotation stereotypes.- Parameters:
element- The elementstereotypes- The stereotypes- Returns:
- True if it is
-
hasStereotype
protected boolean hasStereotype(javax.lang.model.element.Element element, java.util.List<java.lang.String> stereotypes)Return whether the given element is annotated with any of the given annotation stereotypes.- Parameters:
element- The elementstereotypes- The stereotypes- Returns:
- True if it is
-
getAnnotationMetadata
public io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata(javax.lang.model.element.Element element)
Get the annotation metadata for the given element.- Parameters:
element- The element- Returns:
- The
AnnotationMetadata
-
getDeclaredAnnotationMetadata
public io.micronaut.core.annotation.AnnotationMetadata getDeclaredAnnotationMetadata(javax.lang.model.element.Element element)
Get the declared annotation metadata for the given element.- Parameters:
element- The element- Returns:
- The
AnnotationMetadata
-
getAnnotationMetadata
public io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata(javax.lang.model.element.Element parent, javax.lang.model.element.Element element)Get the annotation metadata for the given element and the given parent. This method is used for cases when you need to combine annotation metadata for two elements, for example a JavaBean property where the field and the method metadata need to be combined.- Parameters:
parent- The parentelement- The element- Returns:
- The
AnnotationMetadata
-
getAnnotationMetadata
public io.micronaut.core.annotation.AnnotationMetadata getAnnotationMetadata(java.util.List<javax.lang.model.element.Element> parents, javax.lang.model.element.Element element)Get the annotation metadata for the given element and the given parents. This method is used for cases when you need to combine annotation metadata for two elements, for example a JavaBean property where the field and the method metadata need to be combined.- Parameters:
parents- The parentselement- The element- Returns:
- The
AnnotationMetadata
-
isAnnotated
public boolean isAnnotated(java.lang.String declaringType, javax.lang.model.element.ExecutableElement method)Check whether the method is annotated.- Parameters:
declaringType- The declaring typemethod- The method- Returns:
- True if it is annotated with non internal annotations
-
newAnnotationBuilder
public JavaAnnotationMetadataBuilder newAnnotationBuilder()
Creates a new annotation builder.- Returns:
- The builder
-
newVisitorContext
public JavaVisitorContext newVisitorContext()
Creates a newJavaVisitorContext.- Returns:
- The visitor context
-
invalidateMetadata
@Internal public static void invalidateMetadata(javax.lang.model.element.Element element)
Invalidates any cached metadata.- Parameters:
element- The element
-
-