Class 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 of ElementVisitor 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  
      • Fields inherited from class javax.lang.model.util.SimpleElementVisitor6

        DEFAULT_VALUE
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected AnnotatedElementJSONElementVisitor​(javax.annotation.processing.ProcessingEnvironment processingEnv, java.lang.String annotationClassName)  
    • 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
    • Constructor Detail

      • AnnotatedElementJSONElementVisitor

        protected AnnotatedElementJSONElementVisitor​(javax.annotation.processing.ProcessingEnvironment processingEnv,
                                                     java.lang.String annotationClassName)
    • 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 class JSONElementVisitor
        Parameters:
        e - the element to check
        Returns:
        true if the element is supported; false otherwise