Class GroovyFieldElement

All Implemented Interfaces:
AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Named, MutableAnnotationMetadataDelegate<Element>, Element, FieldElement, MemberElement, TypedElement

@Internal public class GroovyFieldElement extends AbstractGroovyElement implements FieldElement
A field element returning data from a FieldNode. The variable could be a field or property node.
Since:
1.0
Author:
James Kleeh
  • Method Details

    • copyConstructor

      protected AbstractGroovyElement copyConstructor()
      Description copied from class: AbstractGroovyElement
      Constructs this element by invoking the constructor.
      Specified by:
      copyConstructor in class AbstractGroovyElement
      Returns:
      the copy
    • withAnnotationMetadata

      public 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 FieldElement
      Specified by:
      withAnnotationMetadata in interface MemberElement
      Overrides:
      withAnnotationMetadata in class AbstractGroovyElement
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      A new element
    • getOwningType

      public GroovyClassElement getOwningType()
      Description copied from interface: MemberElement
      The owing type is the type that owns this element. This can differ from MemberElement.getDeclaringType() in the case of inheritance since this method will return the subclass that owners the inherited member, whilst MemberElement.getDeclaringType() will return the super class that declares the type.
      Specified by:
      getOwningType in interface MemberElement
      Returns:
      The owning type.
    • getModifiers

      public Set<ElementModifier> getModifiers()
      Specified by:
      getModifiers in interface Element
      Specified by:
      getModifiers in interface MemberElement
      Returns:
      The ElementModifier types for this class element
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getGenericField

      public ClassElement getGenericField()
      Description copied from interface: FieldElement
      Obtain the generic type with the associated annotation metadata for the field.
      Specified by:
      getGenericField in interface FieldElement
      Returns:
      The generic field
    • isPrimitive

      public boolean isPrimitive()
      Description copied from interface: TypedElement
      Whether the type is primitive.
      Specified by:
      isPrimitive in interface TypedElement
      Returns:
      True if it is
    • isArray

      public boolean isArray()
      Description copied from interface: TypedElement
      Is the type an array.
      Specified by:
      isArray in interface TypedElement
      Returns:
      True if it is.
    • getArrayDimensions

      public int getArrayDimensions()
      Description copied from interface: TypedElement
      If the type is an array, the number of dimensions. String[] should return 1, String[][] should return 2
      Specified by:
      getArrayDimensions in interface TypedElement
      Returns:
      The number of dimensions
    • getName

      public String getName()
      Specified by:
      getName in interface Element
      Specified by:
      getName in interface Named
      Returns:
      The name of the element. For a type this represents the binary name.
    • isAbstract

      public boolean isAbstract()
      Specified by:
      isAbstract in interface Element
      Returns:
      True if the element is abstract.
    • isStatic

      public boolean isStatic()
      Specified by:
      isStatic in interface Element
      Returns:
      True if the element is static.
    • isPublic

      public boolean isPublic()
      Specified by:
      isPublic in interface Element
      Returns:
      True if the element is public.
    • isPrivate

      public boolean isPrivate()
      Specified by:
      isPrivate in interface Element
      Returns:
      True if the element is private.
    • isFinal

      public boolean isFinal()
      Specified by:
      isFinal in interface Element
      Returns:
      True if the element is final.
    • isProtected

      public boolean isProtected()
      Specified by:
      isProtected in interface Element
      Returns:
      True if the element is protected.
    • isPackagePrivate

      public boolean isPackagePrivate()
      Specified by:
      isPackagePrivate in interface Element
      Overrides:
      isPackagePrivate in class AbstractGroovyElement
      Returns:
      True if the element is package private.
    • getConstantValue

      public Object getConstantValue()
      Description copied from interface: FieldElement
      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.

      Specified by:
      getConstantValue in interface FieldElement
      Returns:
      the value of this variable if this is a final field initialized to a compile-time constant, or null otherwise
    • getType

      @NonNull public @NonNull ClassElement getType()
      Specified by:
      getType in interface TypedElement
      Returns:
      The type of the element
    • getGenericType

      public ClassElement getGenericType()
      Description copied from interface: TypedElement
      Returns the generic type of the element. This differs from TypedElement.getType() as it returns the actual type without erasure. Whilst TypedElement.getType() is often needed to produce the correct byte code when generating code via ASM, the getGenericType() method is more useful for documentation and other types of code generation.
      Specified by:
      getGenericType in interface TypedElement
      Returns:
      The generic type
    • getDeclaringType

      public GroovyClassElement getDeclaringType()
      Specified by:
      getDeclaringType in interface MemberElement
      Returns:
      The declaring type of the element.