Class AnnotatedElementJSONElementVisitor
- java.lang.Object
-
- javax.lang.model.util.AbstractElementVisitor6<R,P>
-
- javax.lang.model.util.SimpleElementVisitor6<R,P>
-
- javax.lang.model.util.ElementKindVisitor6<java.lang.Boolean,java.lang.StringBuilder>
-
- io.microsphere.annotation.processor.model.util.JSONElementVisitor
-
- io.microsphere.annotation.processor.model.util.AnnotatedElementJSONElementVisitor
-
- All Implemented Interfaces:
javax.lang.model.element.ElementVisitor<java.lang.Boolean,java.lang.StringBuilder>
- Direct Known Subclasses:
ConfigurationPropertyJSONElementVisitor
public abstract class AnnotatedElementJSONElementVisitor extends JSONElementVisitor
An abstract implementation ofElementVisitor
that generates JSON content for elements annotated with a specific annotation.This class extends
JSONElementVisitor
, providing functionality to filter and process only those elements that are annotated with the specified annotation. It leverages the annotation processing environment to gather information about the annotated elements and constructs JSON representations accordingly.Example Usage
Suppose you have a custom annotation:
{@code
- Since:
- 1.0.0
- Author:
- Mercy
- See Also:
JSONElementVisitor
,AnnotatedElement
,Annotation
,ElementType
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.String
annotationClassName
protected javax.lang.model.type.DeclaredType
annotationType
protected javax.lang.model.element.TypeElement
annotationTypeElement
protected javax.lang.model.util.Elements
elements
protected java.lang.annotation.ElementType[]
elementTypes
protected javax.annotation.processing.ProcessingEnvironment
processingEnv
-
Constructor Summary
Constructors Modifier Constructor Description protected
AnnotatedElementJSONElementVisitor(javax.annotation.processing.ProcessingEnvironment processingEnv, java.lang.String annotationClassName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getAnnotationClassName()
Get the annotation class nameprotected boolean
supports(javax.lang.model.element.Element e)
Determines whether the specified element is supported for processing.-
Methods inherited from class io.microsphere.annotation.processor.model.util.JSONElementVisitor
doVisitPackage, doVisitTypeParameter, supportsExecutable, supportsPackage, supportsType, supportsTypeParameter, supportsVariable, visitExecutable, visitMembers, visitPackage, visitType, visitTypeParameter, visitVariable
-
Methods inherited from class javax.lang.model.util.ElementKindVisitor6
visitExecutableAsConstructor, visitExecutableAsInstanceInit, visitExecutableAsMethod, visitExecutableAsStaticInit, visitTypeAsAnnotationType, visitTypeAsClass, visitTypeAsEnum, visitTypeAsInterface, visitVariableAsEnumConstant, visitVariableAsExceptionParameter, visitVariableAsField, visitVariableAsLocalVariable, visitVariableAsParameter, visitVariableAsResourceVariable
-
-
-
-
Field Detail
-
processingEnv
protected final javax.annotation.processing.ProcessingEnvironment processingEnv
-
elements
protected final javax.lang.model.util.Elements elements
-
annotationClassName
protected final java.lang.String annotationClassName
-
annotationType
protected final javax.lang.model.type.DeclaredType annotationType
-
annotationTypeElement
protected final javax.lang.model.element.TypeElement annotationTypeElement
-
elementTypes
protected final java.lang.annotation.ElementType[] elementTypes
-
-
Method Detail
-
getAnnotationClassName
@Nonnull public final java.lang.String getAnnotationClassName()
Get the annotation class name- Returns:
- the annotation class name
-
supports
protected boolean supports(javax.lang.model.element.Element e)
Description copied from class:JSONElementVisitor
Determines whether the specified element is supported for processing.This method can be overridden to provide custom logic for deciding if an element should be processed by this visitor.
- Overrides:
supports
in classJSONElementVisitor
- Parameters:
e
- the element to check- Returns:
true
if the element is supported;false
otherwise
-
-