T
- The element typeA
- The annotation typepublic abstract class AbstractAnnotationMetadataBuilder<T,A> extends Object
AnnotationMetadata
.Modifier | Constructor and Description |
---|---|
protected |
AbstractAnnotationMetadataBuilder()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
addError(T originatingElement,
String error)
Adds an error.
|
static void |
addMutatedMetadata(String declaringType,
Object element,
AnnotationMetadata metadata)
Used to store metadata mutations at compilation time.
|
<A2 extends Annotation> |
annotate(AnnotationMetadata annotationMetadata,
AnnotationValue<A2> annotationValue)
Annotate an existing annotation metadata object.
|
AnnotationMetadata |
build(String declaringType,
T element)
Build the meta data for the given element.
|
AnnotationMetadata |
build(T element)
Build the meta data for the given element.
|
AnnotationMetadata |
buildDeclared(T element)
Build only metadata for declared annotations.
|
AnnotationMetadata |
buildForMethod(T element)
Build the meta data for the given method element excluding any class metadata.
|
AnnotationMetadata |
buildForParent(String declaringType,
T parent,
T element)
Build the meta data for the given parent and method element excluding any class metadata.
|
AnnotationMetadata |
buildForParent(T parent,
T element)
Get the annotation metadata for the given element and the given parent.
|
AnnotationMetadata |
buildForParent(T parent,
T element,
boolean inheritTypeAnnotations)
Build the meta data for the given method element excluding any class metadata.
|
protected abstract List<T> |
buildHierarchy(T element,
boolean inheritTypeAnnotations,
boolean declaredOnly)
Build the type hierarchy for the given element.
|
AnnotationMetadata |
buildOverridden(T element)
Build metadata for the given element, including any metadata that is inherited via method or type overrides.
|
static void |
clearMutated()
Used to clear mutated metadata at the end of a compilation cycle.
|
protected abstract VisitorContext |
createVisitorContext()
Creates the visitor context for this implementation.
|
protected abstract String |
getAnnotationMemberName(T member)
Read the name of an annotation member.
|
protected abstract Optional<T> |
getAnnotationMirror(String annotationName)
Return a mirror for the given annotation.
|
protected abstract List<? extends A> |
getAnnotationsForType(T element)
Obtain the annotations for the given type.
|
protected abstract String |
getAnnotationTypeName(A annotationMirror)
Get the given type of the annotation.
|
protected abstract OptionalValues<?> |
getAnnotationValues(T originatingElement,
T member,
Class<?> annotationType)
Resolve the annotations values from the given member for the given type.
|
protected abstract String |
getDeclaringType(T element)
Obtains the declaring type for an element.
|
protected abstract String |
getElementName(T element)
Get the name for the given element.
|
protected AnnotatedElementValidator |
getElementValidator()
Obtains the element validator.
|
static Set<String> |
getMappedAnnotationNames() |
protected abstract String |
getRepeatableName(A annotationMirror)
Obtain the name of the repeatable annotation if the annotation is is one.
|
protected abstract String |
getRepeatableNameForType(T annotationType)
Obtain the name of the repeatable annotation if the annotation is is one.
|
protected abstract T |
getTypeForAnnotation(A annotationMirror)
Get the type of the given annotation.
|
protected abstract boolean |
hasAnnotation(T element,
Class<? extends Annotation> annotation)
Checks whether an annotation is present.
|
static boolean |
isAnnotationMapped(String annotationName)
Returns whether the given annotation is a mapped annotation.
|
static boolean |
isMetadataMutated(String declaringType,
Object element)
Used to store metadata mutations at compilation time.
|
protected abstract boolean |
isMethodOrClassElement(T element)
Whether the element is a field, method, class or constructor.
|
protected Map<CharSequence,Object> |
populateAnnotationData(T originatingElement,
A annotationMirror,
DefaultAnnotationMetadata metadata,
boolean isDeclared)
Populate the annotation data for the given annotation.
|
protected abstract Map<? extends T,?> |
readAnnotationDefaultValues(A annotationMirror)
Read the raw default annotation values from the given annotation.
|
protected abstract Map<? extends T,?> |
readAnnotationDefaultValues(String annotationName,
T annotationType)
Read the raw default annotation values from the given annotation.
|
protected abstract Map<? extends T,?> |
readAnnotationRawValues(A annotationMirror)
Read the raw annotation values from the given annotation.
|
protected abstract void |
readAnnotationRawValues(T originatingElement,
String annotationName,
T 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 abstract Object |
readAnnotationValue(T originatingElement,
T member,
String memberName,
Object annotationValue)
Read the given member and value, applying conversions if necessary, and place the data in the given map.
|
protected AnnotationValue |
readNestedAnnotationValue(T originatingElement,
A annotationMirror) |
protected void |
validateAnnotationValue(T originatingElement,
String annotationName,
T member,
String memberName,
Object resolvedValue)
Validates an annotation value.
|
protected AbstractAnnotationMetadataBuilder()
public AnnotationMetadata buildDeclared(T element)
element
- The elementAnnotationMetadata
public AnnotationMetadata buildOverridden(T element)
element
- The elementAnnotationMetadata
public AnnotationMetadata build(T element)
element
- The elementAnnotationMetadata
public AnnotationMetadata build(String declaringType, T element)
declaringType
- The declaring typeelement
- The elementAnnotationMetadata
protected abstract boolean isMethodOrClassElement(T element)
element
- The element@Nonnull protected abstract String getDeclaringType(@Nonnull T element)
element
- The elementpublic AnnotationMetadata buildForMethod(T element)
element
- The elementAnnotationMetadata
public AnnotationMetadata buildForParent(T parent, T element)
parent
- The parent elementelement
- The elementAnnotationMetadata
public AnnotationMetadata buildForParent(String declaringType, T parent, T element)
declaringType
- The declaring typeparent
- The parent elementelement
- The elementAnnotationMetadata
public AnnotationMetadata buildForParent(T parent, T element, boolean inheritTypeAnnotations)
parent
- The parent elementelement
- The elementinheritTypeAnnotations
- Whether to inherit annotations from type as stereotypesAnnotationMetadata
protected abstract T getTypeForAnnotation(A annotationMirror)
annotationMirror
- The annotationprotected abstract boolean hasAnnotation(T element, Class<? extends Annotation> annotation)
element
- The elementannotation
- The annotation typeprotected abstract String getAnnotationTypeName(A annotationMirror)
annotationMirror
- The annotationprotected abstract String getElementName(T element)
element
- The elementprotected abstract List<? extends A> getAnnotationsForType(T element)
element
- The type elementprotected abstract List<T> buildHierarchy(T element, boolean inheritTypeAnnotations, boolean declaredOnly)
element
- The elementinheritTypeAnnotations
- Whether to inherit type annotationsdeclaredOnly
- Whether to only include declared annotationsprotected abstract void readAnnotationRawValues(T originatingElement, String annotationName, T member, String memberName, Object annotationValue, Map<CharSequence,Object> annotationValues)
originatingElement
- The originating elementannotationName
- The annotation namemember
- The member being read frommemberName
- The memberannotationValue
- The valueannotationValues
- The values to populateprotected void validateAnnotationValue(T originatingElement, String annotationName, T member, String memberName, Object resolvedValue)
originatingElement
- The originating elementannotationName
- The annotation namemember
- The membermemberName
- The member nameresolvedValue
- The resolved value@Nullable protected AnnotatedElementValidator getElementValidator()
protected abstract void addError(@Nonnull T originatingElement, @Nonnull String error)
originatingElement
- The originating elementerror
- The errorprotected abstract Object readAnnotationValue(T originatingElement, T member, String memberName, Object annotationValue)
originatingElement
- The originating elementmember
- The membermemberName
- The member nameannotationValue
- The valueprotected abstract Map<? extends T,?> readAnnotationDefaultValues(A annotationMirror)
annotationMirror
- The annotationprotected abstract Map<? extends T,?> readAnnotationDefaultValues(String annotationName, T annotationType)
annotationName
- annotation nameannotationType
- the typeprotected abstract Map<? extends T,?> readAnnotationRawValues(A annotationMirror)
annotationMirror
- The annotationprotected abstract OptionalValues<?> getAnnotationValues(T originatingElement, T member, Class<?> annotationType)
originatingElement
- The originating elementmember
- The memberannotationType
- The typeprotected abstract String getAnnotationMemberName(T member)
member
- The member@Nullable protected abstract String getRepeatableName(A annotationMirror)
annotationMirror
- The annotation mirror@Nullable protected abstract String getRepeatableNameForType(T annotationType)
annotationType
- The annotation mirrorprotected AnnotationValue readNestedAnnotationValue(T originatingElement, A annotationMirror)
originatingElement
- The originating elementannotationMirror
- The annotationprotected abstract Optional<T> getAnnotationMirror(String annotationName)
annotationName
- The annotation nameprotected Map<CharSequence,Object> populateAnnotationData(T originatingElement, A annotationMirror, DefaultAnnotationMetadata metadata, boolean isDeclared)
originatingElement
- The element the annotation data originates fromannotationMirror
- The annotationmetadata
- the metadataisDeclared
- Is the annotation a declared annotationprotected abstract VisitorContext createVisitorContext()
@Internal public static void addMutatedMetadata(String declaringType, Object element, AnnotationMetadata metadata)
declaringType
- The declaring typeelement
- The elementmetadata
- The metadata@Internal public static boolean isMetadataMutated(String declaringType, Object element)
declaringType
- The declaring typeelement
- The element@Internal public static void clearMutated()
@Internal public static boolean isAnnotationMapped(@Nullable String annotationName)
annotationName
- The annotation name@Internal public static Set<String> getMappedAnnotationNames()
public <A2 extends Annotation> AnnotationMetadata annotate(AnnotationMetadata annotationMetadata, AnnotationValue<A2> annotationValue)
A2
- The annotation typeannotationMetadata
- The annotation metadataannotationValue
- The annotation value