public class JavaAnnotationMetadataBuilder extends AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
AnnotationMetadata
for builder for Java to be used at compile time.Constructor and Description |
---|
JavaAnnotationMetadataBuilder(javax.lang.model.util.Elements elements,
javax.annotation.processing.Messager messager,
AnnotationUtils annotationUtils,
ModelUtils modelUtils)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addError(javax.lang.model.element.Element originatingElement,
java.lang.String error)
Adds an error.
|
protected java.util.List<javax.lang.model.element.Element> |
buildHierarchy(javax.lang.model.element.Element element,
boolean inheritTypeAnnotations,
boolean declaredOnly)
Build the type hierarchy for the given element.
|
protected VisitorContext |
createVisitorContext()
Creates the visitor context for this implementation.
|
protected javax.lang.model.element.Element |
getAnnotationMember(javax.lang.model.element.Element originatingElement,
java.lang.CharSequence member)
Get the annotation member.
|
protected java.lang.String |
getAnnotationMemberName(javax.lang.model.element.Element member)
Read the name of an annotation member.
|
protected java.util.Optional<javax.lang.model.element.Element> |
getAnnotationMirror(java.lang.String annotationName)
Return a mirror for the given annotation.
|
protected java.util.List<? extends javax.lang.model.element.AnnotationMirror> |
getAnnotationsForType(javax.lang.model.element.Element element)
Obtain the annotations for the given type.
|
protected java.lang.String |
getAnnotationTypeName(javax.lang.model.element.AnnotationMirror annotationMirror)
Get the given type of the annotation.
|
protected OptionalValues<?> |
getAnnotationValues(javax.lang.model.element.Element originatingElement,
javax.lang.model.element.Element member,
java.lang.Class<?> annotationType)
Resolve the annotations values from the given member for the given type.
|
protected java.lang.String |
getDeclaringType(javax.lang.model.element.Element element)
Obtains the declaring type for an element.
|
protected java.lang.String |
getElementName(javax.lang.model.element.Element element)
Get the name for the given element.
|
protected AnnotatedElementValidator |
getElementValidator()
Obtains the element validator.
|
protected java.lang.String |
getRepeatableName(javax.lang.model.element.AnnotationMirror annotationMirror)
Obtain the name of the repeatable annotation if the annotation is is one.
|
protected java.lang.String |
getRepeatableNameForType(javax.lang.model.element.Element annotationType)
Obtain the name of the repeatable annotation if the annotation is is one.
|
protected java.lang.annotation.RetentionPolicy |
getRetentionPolicy(javax.lang.model.element.Element annotation)
Gets the retention policy for the given annotation.
|
protected javax.lang.model.element.Element |
getTypeForAnnotation(javax.lang.model.element.AnnotationMirror annotationMirror)
Get the type of the given annotation.
|
boolean |
hasAnnotation(javax.lang.model.element.Element element,
java.lang.Class<? extends java.lang.annotation.Annotation> ann)
Checks if a method has an annotation.
|
static boolean |
hasAnnotation(javax.lang.model.element.ExecutableElement method,
java.lang.Class<? extends java.lang.annotation.Annotation> ann)
Checks if a method has an annotation.
|
protected boolean |
isMethodOrClassElement(javax.lang.model.element.Element element)
Whether the element is a field, method, class or constructor.
|
protected java.util.Map<? extends javax.lang.model.element.Element,?> |
readAnnotationDefaultValues(javax.lang.model.element.AnnotationMirror annotationMirror)
Read the raw default annotation values from the given annotation.
|
protected java.util.Map<? extends javax.lang.model.element.Element,?> |
readAnnotationDefaultValues(java.lang.String annotationTypeName,
javax.lang.model.element.Element element)
Read the raw default annotation values from the given annotation.
|
protected java.util.Map<? extends javax.lang.model.element.Element,?> |
readAnnotationRawValues(javax.lang.model.element.AnnotationMirror annotationMirror)
Read the raw annotation values from the given annotation.
|
protected void |
readAnnotationRawValues(javax.lang.model.element.Element originatingElement,
java.lang.String annotationName,
javax.lang.model.element.Element member,
java.lang.String memberName,
java.lang.Object annotationValue,
java.util.Map<java.lang.CharSequence,java.lang.Object> annotationValues)
Read the given member and value, applying conversions if necessary, and place the data in the given map.
|
protected java.lang.Object |
readAnnotationValue(javax.lang.model.element.Element originatingElement,
javax.lang.model.element.Element member,
java.lang.String memberName,
java.lang.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, buildForMethod, buildForParent, buildForParent, buildForParent, buildOverridden, clearMutated, getAnnotationMappers, getMappedAnnotationNames, isAnnotationMapped, isMetadataMutated, populateAnnotationData, readNestedAnnotationValue, validateAnnotationValue
public JavaAnnotationMetadataBuilder(javax.lang.model.util.Elements elements, javax.annotation.processing.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<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
protected void addError(@NonNull javax.lang.model.element.Element originatingElement, @NonNull java.lang.String error)
AbstractAnnotationMetadataBuilder
addError
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
originatingElement
- The originating elementerror
- The errorprotected java.lang.String getAnnotationMemberName(javax.lang.model.element.Element member)
AbstractAnnotationMetadataBuilder
getAnnotationMemberName
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
member
- The member@Nullable protected java.lang.String getRepeatableName(javax.lang.model.element.AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
getRepeatableName
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationMirror
- The annotation mirror@Nullable protected java.lang.String getRepeatableNameForType(javax.lang.model.element.Element annotationType)
AbstractAnnotationMetadataBuilder
getRepeatableNameForType
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationType
- The annotation mirrorprotected java.util.Optional<javax.lang.model.element.Element> getAnnotationMirror(java.lang.String annotationName)
AbstractAnnotationMetadataBuilder
getAnnotationMirror
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationName
- The annotation nameprotected VisitorContext createVisitorContext()
AbstractAnnotationMetadataBuilder
createVisitorContext
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
@NonNull protected java.lang.annotation.RetentionPolicy getRetentionPolicy(@NonNull javax.lang.model.element.Element annotation)
AbstractAnnotationMetadataBuilder
getRetentionPolicy
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotation
- The annotationprotected boolean isMethodOrClassElement(javax.lang.model.element.Element element)
AbstractAnnotationMetadataBuilder
isMethodOrClassElement
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
element
- The element@NonNull protected java.lang.String getDeclaringType(@NonNull javax.lang.model.element.Element element)
AbstractAnnotationMetadataBuilder
getDeclaringType
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
element
- The elementprotected javax.lang.model.element.Element getTypeForAnnotation(javax.lang.model.element.AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
getTypeForAnnotation
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationMirror
- The annotationprotected java.util.List<? extends javax.lang.model.element.AnnotationMirror> getAnnotationsForType(javax.lang.model.element.Element element)
AbstractAnnotationMetadataBuilder
getAnnotationsForType
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
element
- The type elementprotected java.util.List<javax.lang.model.element.Element> buildHierarchy(javax.lang.model.element.Element element, boolean inheritTypeAnnotations, boolean declaredOnly)
AbstractAnnotationMetadataBuilder
buildHierarchy
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
element
- The elementinheritTypeAnnotations
- Whether to inherit type annotationsdeclaredOnly
- Whether to only include declared annotationsprotected java.util.Map<? extends javax.lang.model.element.Element,?> readAnnotationRawValues(javax.lang.model.element.AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
readAnnotationRawValues
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationMirror
- The annotation@Nullable protected javax.lang.model.element.Element getAnnotationMember(javax.lang.model.element.Element originatingElement, java.lang.CharSequence member)
AbstractAnnotationMetadataBuilder
getAnnotationMember
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
originatingElement
- The originatig elementmember
- The memberprotected OptionalValues<?> getAnnotationValues(javax.lang.model.element.Element originatingElement, javax.lang.model.element.Element member, java.lang.Class<?> annotationType)
AbstractAnnotationMetadataBuilder
getAnnotationValues
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
originatingElement
- The originating elementmember
- The memberannotationType
- The typeprotected void readAnnotationRawValues(javax.lang.model.element.Element originatingElement, java.lang.String annotationName, javax.lang.model.element.Element member, java.lang.String memberName, java.lang.Object annotationValue, java.util.Map<java.lang.CharSequence,java.lang.Object> annotationValues)
AbstractAnnotationMetadataBuilder
readAnnotationRawValues
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
originatingElement
- The originating elementannotationName
- The annotation namemember
- The member being read frommemberName
- The memberannotationValue
- The valueannotationValues
- The values to populateprotected java.lang.Object readAnnotationValue(javax.lang.model.element.Element originatingElement, javax.lang.model.element.Element member, java.lang.String memberName, java.lang.Object annotationValue)
AbstractAnnotationMetadataBuilder
readAnnotationValue
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
originatingElement
- The originating elementmember
- The membermemberName
- The member nameannotationValue
- The valueprotected java.util.Map<? extends javax.lang.model.element.Element,?> readAnnotationDefaultValues(javax.lang.model.element.AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
readAnnotationDefaultValues
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationMirror
- The annotationprotected java.util.Map<? extends javax.lang.model.element.Element,?> readAnnotationDefaultValues(java.lang.String annotationTypeName, javax.lang.model.element.Element element)
AbstractAnnotationMetadataBuilder
readAnnotationDefaultValues
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationTypeName
- annotation nameelement
- the typeprotected java.lang.String getAnnotationTypeName(javax.lang.model.element.AnnotationMirror annotationMirror)
AbstractAnnotationMetadataBuilder
getAnnotationTypeName
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
annotationMirror
- The annotationprotected java.lang.String getElementName(javax.lang.model.element.Element element)
AbstractAnnotationMetadataBuilder
getElementName
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
element
- The elementpublic boolean hasAnnotation(javax.lang.model.element.Element element, java.lang.Class<? extends java.lang.annotation.Annotation> ann)
hasAnnotation
in class AbstractAnnotationMetadataBuilder<javax.lang.model.element.Element,javax.lang.model.element.AnnotationMirror>
element
- The methodann
- The annotation to look forpublic static boolean hasAnnotation(javax.lang.model.element.ExecutableElement method, java.lang.Class<? extends java.lang.annotation.Annotation> ann)
method
- The methodann
- The annotation to look for