Interface Element

All Superinterfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, MutableAnnotationMetadataDelegate<Element>, Named
All Known Subinterfaces:
AnnotationElement, ArrayableClassElement, BeanConstructorElement, BeanElement, BeanElementBuilder, BeanFieldElement, BeanMethodElement, BeanParameterElement, ClassElement, ConfigurableElement, ConstructorElement, EnumConstantElement, EnumElement, FieldElement, GenericElement, GenericPlaceholderElement, InjectableElement, KotlinParameterElement, MemberElement, MethodElement, PackageElement, ParameterElement, PropertyElement, TypedElement, WildcardElement
All Known Implementing Classes:
AbstractAnnotationElement, AbstractBeanDefinitionBuilder, AbstractGroovyElement, AbstractJavaElement, BeanDefinitionWriter, GroovyClassElement, GroovyConstructorElement, GroovyEnumConstantElement, GroovyFieldElement, GroovyMethodElement, GroovyPackageElement, GroovyParameterElement, JavaClassElement, JavaMethodElement, JavaPackageElement, PrimitiveElement

Stores data about a compile time element. The underlying object can be a class, field, or method.
Since:
1.0
Author:
James Kleeh, graemerocher
  • Field Details

    • EMPTY_ELEMENT_ARRAY

      static final Element[] EMPTY_ELEMENT_ARRAY
      An empty array of elements.
      Since:
      2.1.1
  • Method Details

    • getName

      Specified by:
      getName in interface Named
      Returns:
      The name of the element. For a type this represents the binary name.
    • isPackagePrivate

      default boolean isPackagePrivate()
      Returns:
      True if the element is package private.
      Since:
      2.3.0
    • isSynthetic

      default boolean isSynthetic()
      Checks if the current element is synthetic - not user defined but created by the compiler.
      Returns:
      True if the element is synthetic.
      Since:
      4.0.0
    • isProtected

      boolean isProtected()
      Returns:
      True if the element is protected.
    • isPublic

      boolean isPublic()
      Returns:
      True if the element is public.
    • getNativeType

      @NonNull @NonNull Object getNativeType()
      Returns the native underlying type. This API is extended by all inject language implementations. The object returned by this method will be the language native type the information is being retrieved from.
      Returns:
      The native type
    • getModifiers

      default Set<ElementModifier> getModifiers()
      Returns:
      The ElementModifier types for this class element
      Since:
      3.0.0
    • getSimpleName

      @NonNull default @NonNull String getSimpleName()
      The simple name of the element. For a class this will be the name without the package.
      Returns:
      The simple name
    • isAbstract

      default boolean isAbstract()
      Returns:
      True if the element is abstract.
    • isStatic

      default boolean isStatic()
      Returns:
      True if the element is static.
    • getDocumentation

      default Optional<String> getDocumentation()
      Returns:
      The documentation, if any.
    • isPrivate

      default boolean isPrivate()
      Returns:
      True if the element is private.
    • isFinal

      default boolean isFinal()
      Returns:
      True if the element is final.
    • getDescription

      @NonNull default @NonNull String getDescription()
      Description copied from interface: Described
      A description that describes this object.
      Specified by:
      getDescription in interface Described
      Returns:
      The description
    • getDescription

      @NonNull default @NonNull String getDescription(boolean simple)
      Description copied from interface: Described
      Allows returning a more simple description if requested.
      Specified by:
      getDescription in interface Described
      Parameters:
      simple - True if a simple description is required
      Returns:
      The simple description
    • withAnnotationMetadata

      default Element withAnnotationMetadata(AnnotationMetadata annotationMetadata)
      Copies this element and overrides its annotations.
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      A new element
      Since:
      4.0.0
    • annotate

      default <T extends Annotation> Element annotate(String annotationType, Consumer<AnnotationValueBuilder<T>> consumer)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.
      Specified by:
      annotate in interface MutableAnnotationMetadataDelegate<Element>
      Type Parameters:
      T - The annotation generic type
      Parameters:
      annotationType - The annotation type
      consumer - A function that receives the AnnotationValueBuilder
      Returns:
      This element
    • removeAnnotation

      default Element removeAnnotation(String annotationType)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Removes an annotation of the given type from the element.

      If the annotation features any stereotypes these will also be removed unless there are other annotations that reference the stereotype to be removed.

      In the case of repeatable annotations this method will remove all repeated annotations, effectively clearing out all declared repeated annotations of the given type.

      Specified by:
      removeAnnotation in interface MutableAnnotationMetadataDelegate<Element>
      Parameters:
      annotationType - The annotation type
      Returns:
      This element
    • removeAnnotation

      default <T extends Annotation> Element removeAnnotation(Class<T> annotationType)
      Specified by:
      removeAnnotation in interface MutableAnnotationMetadataDelegate<Element>
      Type Parameters:
      T - The annotation generic type
      Parameters:
      annotationType - The annotation type
      Returns:
      This element
      See Also:
    • removeAnnotationIf

      default <T extends Annotation> Element removeAnnotationIf(Predicate<AnnotationValue<T>> predicate)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Removes all annotations that pass the given predicate.
      Specified by:
      removeAnnotationIf in interface MutableAnnotationMetadataDelegate<Element>
      Type Parameters:
      T - The annotation generic type
      Parameters:
      predicate - The predicate
      Returns:
      This element
    • removeStereotype

      default Element removeStereotype(String annotationType)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Removes a stereotype of the given name from the element.
      Specified by:
      removeStereotype in interface MutableAnnotationMetadataDelegate<Element>
      Parameters:
      annotationType - The annotation type
      Returns:
      This element
    • removeStereotype

      default <T extends Annotation> Element removeStereotype(Class<T> annotationType)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Removes a stereotype annotation of the given type from the element.
      Specified by:
      removeStereotype in interface MutableAnnotationMetadataDelegate<Element>
      Type Parameters:
      T - The annotation generic type
      Parameters:
      annotationType - The annotation type
      Returns:
      This element
    • annotate

      default Element annotate(String annotationType)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.
      Specified by:
      annotate in interface MutableAnnotationMetadataDelegate<Element>
      Parameters:
      annotationType - The annotation type
      Returns:
      This element
    • annotate

      default <T extends Annotation> Element annotate(Class<T> annotationType, Consumer<AnnotationValueBuilder<T>> consumer)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.
      Specified by:
      annotate in interface MutableAnnotationMetadataDelegate<Element>
      Type Parameters:
      T - The annotation generic type
      Parameters:
      annotationType - The annotation type
      consumer - A function that receives the AnnotationValueBuilder
      Returns:
      This element
    • annotate

      default <T extends Annotation> Element annotate(Class<T> annotationType)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.
      Specified by:
      annotate in interface MutableAnnotationMetadataDelegate<Element>
      Type Parameters:
      T - The annotation generic type
      Parameters:
      annotationType - The annotation type
      Returns:
      This element
    • annotate

      default <T extends Annotation> Element annotate(AnnotationValue<T> annotationValue)
      Description copied from interface: MutableAnnotationMetadataDelegate
      Annotate this element with the given annotation type. If the annotation is already present then any values populated by the builder will be merged/overridden with the existing values.
      Specified by:
      annotate in interface MutableAnnotationMetadataDelegate<Element>
      Type Parameters:
      T - The annotation generic type
      Parameters:
      annotationValue - The annotation type
      Returns:
      This element