Class PythonClassElement

All Implemented Interfaces:
ElementProvider, AnnotatedElement, AnnotationMetadata, AnnotationMetadataDelegate, AnnotationMetadataProvider, AnnotationSource, Described, Named, MutableAnnotationMetadataDelegate<Element>, ArrayableClassElement, ClassElement, Element, TypedElement

public final class PythonClassElement extends AbstractPythonClassElement
Class element implementation for Python classes.
  • Constructor Details

  • Method Details

    • getType

      public @NonNull ClassElement getType()
      Returns:
      The type of the element
    • copyThis

      protected PythonClassElement copyThis()
      Specified by:
      copyThis in class AbstractPythonClassElement
      Returns:
      copy of this element
    • copyValues

      protected void copyValues(io.micronaut.python.processing.visitor.AbstractPythonElement element)
      Overrides:
      copyValues in class AbstractPythonClassElement
      Parameters:
      element - the values to be copied to
    • isPythonSource

      public boolean isPythonSource()
    • addAssociatedBean

      public BeanElementBuilder addAssociatedBean(ClassElement type)
      Description copied from interface: ClassElement
      This method adds an associated bean using this class element as the originating element.

      Note that this method can only be called on classes being directly compiled by Micronaut. If the ClassElement is loaded from pre-compiled code an UnsupportedOperationException will be thrown.

      Parameters:
      type - The type of the bean
      Returns:
      A bean builder
    • isInner

      public boolean isInner()
      Description copied from interface: ClassElement
      Is this type an inner class.
      Returns:
      True if it is an inner class
    • isStatic

      public boolean isStatic()
      Returns:
      True if the element is static.
    • getEnclosingType

      public Optional<ClassElement> getEnclosingType()
      Description copied from interface: ClassElement
      Returns the enclosing type if ClassElement.isInner() return true.
      Returns:
      The enclosing type if any
    • createWithArrayDimensions

      protected ClassElement createWithArrayDimensions(int arrayDimensions)
      Specified by:
      createWithArrayDimensions in class AbstractPythonClassElement
    • toString

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

      public Optional<MethodElement> getDefaultConstructor()
      Description copied from interface: ClassElement
      Find and return a single default constructor. A default constructor is one without arguments that is accessible.
      Returns:
      The default constructor if one is present
    • getPrimaryConstructor

      public Optional<MethodElement> getPrimaryConstructor()
      Description copied from interface: ClassElement
      Find and return a single primary constructor. If more than constructor candidate exists, then return empty unless a constructor is found that is annotated with either Creator or AnnotationUtil.INJECT.
      Returns:
      The primary constructor if one is present
    • isAssignable

      public boolean isAssignable(String type)
      Description copied from interface: ClassElement
      Tests whether one type is assignable to another.
      Parameters:
      type - The type to check
      Returns:
      true if and only if this type is assignable to the second
    • getInterfaces

      public Collection<ClassElement> getInterfaces()
      Specified by:
      getInterfaces in interface ClassElement
      Overrides:
      getInterfaces in class AbstractPythonClassElement
      Returns:
      The interfaces implemented by this class element
    • isInterface

      public boolean isInterface()
      Returns:
      Whether the class element is an interface
    • getSuperType

      public Optional<ClassElement> getSuperType()
      Description copied from interface: ClassElement
      Returns the super type of this element or empty if the element has no super type.
      Returns:
      An optional of the super type
    • getTypeArguments

      public Map<String, ClassElement> getTypeArguments()
      Returns:
      The type arguments for this class element
    • getAllTypeArguments

      public Map<String, Map<String, ClassElement>> getAllTypeArguments()
      Description copied from interface: ClassElement
      Builds a map of all the type parameters for a class, its super classes and interfaces. The resulting map contains the name of the class to the map of the resolved generic types.
      Returns:
      The type arguments for this class element
    • withTypeArguments

      public ClassElement withTypeArguments(Map<String, ClassElement> typeArguments)
      Description copied from interface: ClassElement
      Copies this element and overrides its type arguments.
      Parameters:
      typeArguments - The type arguments
      Returns:
      A new element
    • getDeclaredGenericPlaceholders

      @NonNull public @NonNull List<? extends GenericPlaceholderElement> getDeclaredGenericPlaceholders()
      Description copied from interface: ClassElement
      The type arguments declared on the raw class. Independent of the actual bound type arguments.

      This method will resolve the generic placeholders defined of the declaring class, if any.

      For example List<String> will result a single placeholder called E of type Object.

      Returns:
      The type arguments declared on this class.
    • 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.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object