Record Class ReturnDef

java.lang.Object
java.lang.Record
io.micronaut.python.processing.visitor.ReturnDef
Record Components:
typeAnnotation - The return type annotation, or null if no return type is specified.
decorators - The decorators found on the return type annotation.
All Implemented Interfaces:
ElementDef

public record ReturnDef(TypeRef typeAnnotation, List<DecoratorDef> decorators) extends Record implements ElementDef
A ReturnDef represents the return type annotation of a function.

This record captures the return type annotation from a Python function's type hint (e.g., "-> int", "-> str", "-> List[str]").

Since:
5.2.0
Author:
Micronaut Team
  • Constructor Details

    • ReturnDef

      public ReturnDef(TypeRef typeAnnotation, List<DecoratorDef> decorators)
      Creates an instance of a ReturnDef record class.
      Parameters:
      typeAnnotation - the value for the typeAnnotation record component
      decorators - the value for the decorators record component
  • Method Details

    • none

      public static ReturnDef none()
      Creates a ReturnDef with no return type annotation.
      Returns:
      A new ReturnDef with null type annotation
    • of

      public static ReturnDef of(TypeRef typeAnnotation)
      Creates a ReturnDef with the specified type annotation.
      Parameters:
      typeAnnotation - The return type annotation
      Returns:
      A new ReturnDef
    • of

      public static ReturnDef of(TypeRef typeAnnotation, List<DecoratorDef> decorators)
      Creates a ReturnDef with the specified type annotation and decorators.
      Parameters:
      typeAnnotation - The return type annotation
      decorators - The decorators for the return type
      Returns:
      A new ReturnDef
    • name

      public String name()
      Specified by:
      name in interface ElementDef
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • typeAnnotation

      public TypeRef typeAnnotation()
      Returns the value of the typeAnnotation record component.
      Returns:
      the value of the typeAnnotation record component
    • decorators

      public List<DecoratorDef> decorators()
      Returns the value of the decorators record component.
      Specified by:
      decorators in interface ElementDef
      Returns:
      the value of the decorators record component