Interface FieldElement

All Superinterfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Element, MemberElement, MutableAnnotationMetadataDelegate<Element>, Named, TypedElement
All Known Subinterfaces:
BeanFieldElement, EnumConstantElement
All Known Implementing Classes:
GroovyEnumConstantElement, GroovyFieldElement

public interface FieldElement extends TypedElement, MemberElement
Stores data about an element that references a field.
Since:
1.0
Author:
James Kleeh
  • Method Details

    • getConstantValue

      default Object getConstantValue()
      Returns the value of this variable if this is a final field initialized to a compile-time constant. Returns null otherwise. The value will be of a primitive type or a String. If the value is of a primitive type, it is wrapped in the appropriate wrapper class (such as Integer).

      Note that not all final fields will have constant values. In particular, enum constants are not considered to be compile-time constants. To have a constant value, a field's type must be either a primitive type or String.

      Returns:
      the value of this variable if this is a final field initialized to a compile-time constant, or null otherwise
      Since:
      4.5.0
    • getGenericField

      default ClassElement getGenericField()
      Obtain the generic type with the associated annotation metadata for the field.
      Returns:
      The generic field
    • 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
      Specified by:
      getDescription in interface Element
      Parameters:
      simple - True if a simple description is required
      Returns:
      The simple description
    • withAnnotationMetadata

      default FieldElement withAnnotationMetadata(AnnotationMetadata annotationMetadata)
      Description copied from interface: Element
      Copies this element and overrides its annotations.
      Specified by:
      withAnnotationMetadata in interface Element
      Specified by:
      withAnnotationMetadata in interface MemberElement
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      A new element
    • hides

      default boolean hides(@NonNull @NonNull MemberElement memberElement)
      Description copied from interface: MemberElement
      Checks if this member element hides another.
      Specified by:
      hides in interface MemberElement
      Parameters:
      memberElement - The possibly hidden element
      Returns:
      true if this member element hides passed field element