public class JavaAnnotationMetadataBuilder extends AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
AnnotationMetadata
for builder for Java to be used at compile time.Constructor and Description |
---|
JavaAnnotationMetadataBuilder(Elements elements,
Messager messager,
AnnotationUtils annotationUtils,
ModelUtils modelUtils)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addError(Element originatingElement,
String error)
Adds an error.
|
protected void |
addWarning(Element originatingElement,
String warning)
Adds an warning.
|
protected List<Element> |
buildHierarchy(Element element,
boolean inheritTypeAnnotations,
boolean declaredOnly)
Build the type hierarchy for the given element.
|
static void |
clearCaches()
Clears any caches from the last compilation round.
|
protected VisitorContext |
createVisitorContext()
Creates the visitor context for this implementation.
|
protected Element |
getAnnotationMember(Element originatingElement,
CharSequence member)
Get the annotation member.
|
protected String |
getAnnotationMemberName(Element member)
Read the name of an annotation member.
|
protected Map<String,Element> |
getAnnotationMembers(String annotationType)
Gets the annotation members for the given type.
|
protected Optional<Element> |
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 String |
getAnnotationTypeName(AnnotationMirror annotationMirror)
Get the given type of the annotation.
|
protected OptionalValues<?> |
getAnnotationValues(Element originatingElement,
Element member,
Class<?> annotationType)
Resolve the annotations values from the given member for the given type.
|
protected String |
getDeclaringType(Element element)
Obtains the declaring type for an element.
|
protected String |
getElementName(Element element)
Get the name for the given element.
|
protected AnnotatedElementValidator |
getElementValidator()
Obtains the element validator.
|
protected String |
getRepeatableName(AnnotationMirror annotationMirror)
Obtain the name of the repeatable annotation if the annotation is is one.
|
protected String |
getRepeatableNameForType(Element annotationType)
Obtain the name of the repeatable annotation if the annotation is is one.
|
protected RetentionPolicy |
getRetentionPolicy(Element annotation)
Gets the retention policy for the given annotation.
|
protected Element |
getTypeForAnnotation(AnnotationMirror annotationMirror)
Get the type of the given annotation.
|
boolean |
hasAnnotation(Element element,
Class<? extends Annotation> ann)
Checks if a method has an annotation.
|
boolean |
hasAnnotation(Element element,
String ann)
Checks if a method has an annotation.
|
static boolean |
hasAnnotation(ExecutableElement method,
Class<? extends Annotation> ann)
Checks if a method has an annotation.
|
protected boolean |
hasAnnotations(Element element)
Checks whether any annotations are present on the given element.
|
protected boolean |
hasSimpleAnnotation(Element element,
String simpleName)
Returns true if a simple meta annotation is present for the given element and annotation type.
|
protected boolean |
isExcludedAnnotation(Element element,
String annotationName)
Is the given annotation excluded for the specified element.
|
protected boolean |
isInheritedAnnotation(AnnotationMirror annotationMirror)
Test whether the annotation mirror is inherited.
|
protected boolean |
isInheritedAnnotationType(Element annotationType)
Test whether the annotation mirror is inherited.
|
protected boolean |
isMethodOrClassElement(Element element)
Whether the element is a field, method, class or constructor.
|
protected boolean |
isValidationRequired(Element member)
Return whether the given member requires validation.
|
protected Map<? extends Element,?> |
readAnnotationDefaultValues(AnnotationMirror annotationMirror)
Read the raw default annotation values from the given annotation.
|
protected Map<? extends Element,?> |
readAnnotationDefaultValues(String annotationTypeName,
Element element)
Read the raw default annotation values from the given annotation.
|
protected Map<? extends Element,?> |
readAnnotationRawValues(AnnotationMirror annotationMirror)
Read the raw annotation values from the given annotation.
|
protected void |
readAnnotationRawValues(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 Object |
readAnnotationValue(Element originatingElement,
Element member,
String memberName,
Object annotationValue)
Read the given member and value, applying conversions if necessary, and place the data in the given map.
|
addMutatedMetadata, annotate, build, build, buildDeclared, buildDeclared, buildForMethod, buildForParent, buildForParent, buildForParent, buildForParents, buildForParents, buildOverridden, clearMutated, copyToRuntime, getAnnotationMappers, getAnnotationTransformers, getMappedAnnotationNames, getMappedAnnotationPackages, isAnnotationMapped, isMetadataMutated, populateAnnotationData, populateAnnotationData, readNestedAnnotationValue, removeAnnotation, removeAnnotationIf, removeStereotype, validateAnnotationValue
public JavaAnnotationMetadataBuilder(Elements elements, Messager messager, AnnotationUtils annotationUtils, ModelUtils modelUtils)
elements
- The elementUtilsmessager
- The messagerannotationUtils
- The annotation utilsmodelUtils
- The model utils@Nullable protected AnnotatedElementValidator getElementValidator()
AbstractAnnotationMetadataBuilder
getElementValidator
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
protected void addError(@NonNull Element originatingElement, @NonNull String error)
AbstractAnnotationMetadataBuilder
addError
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
originatingElement
- The originating elementerror
- The errorprotected void addWarning(@NonNull Element originatingElement, @NonNull String warning)
AbstractAnnotationMetadataBuilder
addWarning
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
originatingElement
- The originating elementwarning
- The warningprotected String getAnnotationMemberName(Element member)
AbstractAnnotationMetadataBuilder
getAnnotationMemberName
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
member
- The member@Nullable protected String getRepeatableName(AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
getRepeatableName
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationMirror
- The annotation mirror@Nullable protected String getRepeatableNameForType(Element annotationType)
AbstractAnnotationMetadataBuilder
getRepeatableNameForType
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationType
- The annotation mirrorprotected Optional<Element> getAnnotationMirror(String annotationName)
AbstractAnnotationMetadataBuilder
getAnnotationMirror
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationName
- The annotation nameprotected VisitorContext createVisitorContext()
AbstractAnnotationMetadataBuilder
createVisitorContext
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
@NonNull protected RetentionPolicy getRetentionPolicy(@NonNull Element annotation)
AbstractAnnotationMetadataBuilder
getRetentionPolicy
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotation
- The annotationprotected boolean isInheritedAnnotation(@NonNull AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
isInheritedAnnotation
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationMirror
- The mirrorprotected boolean isInheritedAnnotationType(@NonNull Element annotationType)
AbstractAnnotationMetadataBuilder
isInheritedAnnotationType
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationType
- The mirrorprotected Map<String,Element> getAnnotationMembers(String annotationType)
AbstractAnnotationMetadataBuilder
getAnnotationMembers
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationType
- The annotation typeprotected boolean hasSimpleAnnotation(Element element, String simpleName)
AbstractAnnotationMetadataBuilder
hasSimpleAnnotation
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The elementsimpleName
- The simple name, ie Class.getSimpleName()
protected boolean isMethodOrClassElement(Element element)
AbstractAnnotationMetadataBuilder
isMethodOrClassElement
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The element@NonNull protected String getDeclaringType(@NonNull Element element)
AbstractAnnotationMetadataBuilder
getDeclaringType
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The elementprotected Element getTypeForAnnotation(AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
getTypeForAnnotation
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationMirror
- The annotationprotected List<? extends AnnotationMirror> getAnnotationsForType(Element element)
AbstractAnnotationMetadataBuilder
@Parent(value = {@Child, @Child})
should result in the two
child annotations being returned from this method instead of the
parent annotation.getAnnotationsForType
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The type elementprotected boolean isExcludedAnnotation(@NonNull Element element, @NonNull String annotationName)
AbstractAnnotationMetadataBuilder
isExcludedAnnotation
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The elementannotationName
- The annotation nameprotected List<Element> buildHierarchy(Element element, boolean inheritTypeAnnotations, boolean declaredOnly)
AbstractAnnotationMetadataBuilder
buildHierarchy
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The elementinheritTypeAnnotations
- Whether to inherit type annotationsdeclaredOnly
- Whether to only include declared annotationsprotected Map<? extends Element,?> readAnnotationRawValues(AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
readAnnotationRawValues
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationMirror
- The annotation@Nullable protected Element getAnnotationMember(Element originatingElement, CharSequence member)
AbstractAnnotationMetadataBuilder
getAnnotationMember
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
originatingElement
- The originatig elementmember
- The memberprotected OptionalValues<?> getAnnotationValues(Element originatingElement, Element member, Class<?> annotationType)
AbstractAnnotationMetadataBuilder
getAnnotationValues
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
originatingElement
- The originating elementmember
- The memberannotationType
- The typeprotected void readAnnotationRawValues(Element originatingElement, String annotationName, Element member, String memberName, Object annotationValue, Map<CharSequence,Object> annotationValues)
AbstractAnnotationMetadataBuilder
readAnnotationRawValues
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
originatingElement
- The originating elementannotationName
- The annotation namemember
- The member being read frommemberName
- The memberannotationValue
- The valueannotationValues
- The values to populateprotected boolean isValidationRequired(Element member)
AbstractAnnotationMetadataBuilder
isValidationRequired
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
member
- The memberprotected Object readAnnotationValue(Element originatingElement, Element member, String memberName, Object annotationValue)
AbstractAnnotationMetadataBuilder
readAnnotationValue
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
originatingElement
- The originating elementmember
- The membermemberName
- The member nameannotationValue
- The valueprotected Map<? extends Element,?> readAnnotationDefaultValues(AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
readAnnotationDefaultValues
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationMirror
- The annotationprotected Map<? extends Element,?> readAnnotationDefaultValues(String annotationTypeName, Element element)
AbstractAnnotationMetadataBuilder
readAnnotationDefaultValues
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationTypeName
- annotation nameelement
- the typeprotected String getAnnotationTypeName(AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
getAnnotationTypeName
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
annotationMirror
- The annotationprotected String getElementName(Element element)
AbstractAnnotationMetadataBuilder
getElementName
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The elementpublic boolean hasAnnotation(Element element, Class<? extends Annotation> ann)
hasAnnotation
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The methodann
- The annotation to look forpublic boolean hasAnnotation(Element element, String ann)
hasAnnotation
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The methodann
- The annotation to look forprotected boolean hasAnnotations(Element element)
AbstractAnnotationMetadataBuilder
hasAnnotations
in class AbstractAnnotationMetadataBuilder<Element,AnnotationMirror>
element
- The elementpublic static void clearCaches()
public static boolean hasAnnotation(ExecutableElement method, Class<? extends Annotation> ann)
method
- The methodann
- The annotation to look for