Class PythonFieldElement

java.lang.Object
io.micronaut.inject.ast.annotation.AbstractAnnotationElement
io.micronaut.python.processing.visitor.PythonFieldElement
All Implemented Interfaces:
ElementProvider, AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Named, MutableAnnotationMetadataDelegate<Element>, Element, FieldElement, MemberElement, TypedElement

public final class PythonFieldElement extends AbstractAnnotationElement implements FieldElement, ElementProvider
A field element returning data from a Python AttributeDef.
Since:
5.2.0
Author:
Micronaut Team
  • Constructor Details

  • Method Details

    • getNativeType

      public AttributeDef getNativeType()
      Description copied from interface: Element
      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.
      Specified by:
      getNativeType in interface Element
      Returns:
      The native type
    • getType

      public 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
    • 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
    • isStatic

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

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

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

      public ClassElement getOwningType()
      Description copied from interface: MemberElement
      The owning 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.
    • element

      @Nullable public Element element()
      Specified by:
      element in interface ElementProvider
      Returns:
      The native element.
    • getDocumentation

      public Optional<String> getDocumentation(boolean parseContent)
      Specified by:
      getDocumentation in interface Element
      Parameters:
      parseContent - True if the content should be parsed to extract documentation
      Returns:
      The documentation, if any.
    • equals

      public boolean equals(Object o)
    • hashCode

      public int hashCode()
    • copyThis

      protected io.micronaut.python.processing.visitor.AbstractPythonElement copyThis()
      Returns:
      copy of this element
    • 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
      Parameters:
      annotationMetadata - The annotation metadata
      Returns:
      A new element
    • copyValues

      protected void copyValues(io.micronaut.python.processing.visitor.AbstractPythonElement element)
      Parameters:
      element - the values to be copied to
    • makeCopy

      protected final io.micronaut.python.processing.visitor.AbstractPythonElement makeCopy()
    • 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.
    • isProtected

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

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