Record Class SuperArgumentDef

java.lang.Object
java.lang.Record
io.micronaut.python.processing.model.SuperArgumentDef
Record Components:
source - The argument source text, for diagnostics
keyword - The keyword when the argument was passed by keyword, otherwise null
parameterName - The name of the constructor parameter the argument refers to, otherwise null
type - The static Python type of the argument when it is known (str, int, float, bool, None or the called class), otherwise null
conflictingCall - The source of another super().__init__(...) call of the same constructor that passes different arguments, otherwise null

public record SuperArgumentDef(String source, @Nullable String keyword, @Nullable String parameterName, @Nullable TypeRef type, @Nullable String conflictingCall) extends Record
One argument of the super().__init__(...) call in a Python constructor.

The processor records what it can tell about the argument without running the code: a reference to a constructor parameter, a literal (or f-string) with its Python type, a call of a class, or nothing at all. The stub generator uses the recorded type to pick the Java super constructor that the argument reaches when the Python class extends a Java class.

Since:
5.2.0
Author:
Micronaut Team
  • Constructor Details

  • Method Details

    • parameter

      public static SuperArgumentDef parameter(String source, String parameterName)
      An argument that refers to a constructor parameter.
      Parameters:
      source - The source text
      parameterName - The parameter name
      Returns:
      The argument
    • typed

      public static SuperArgumentDef typed(String source, TypeRef type)
      An argument of a known static type.
      Parameters:
      source - The source text
      type - The Python type
      Returns:
      The argument
    • unknown

      public static SuperArgumentDef unknown(String source)
      An argument whose type the processor cannot tell.
      Parameters:
      source - The source text
      Returns:
      The argument
    • keyword

      public static SuperArgumentDef keyword(String source, String keyword)
      An argument passed by keyword.
      Parameters:
      source - The source text
      keyword - The keyword
      Returns:
      The argument
    • conflicting

      public static SuperArgumentDef conflicting(String source, String conflictingCall)
      The record of a constructor calling super().__init__(...) in more than one way: the arguments of the first call, with the source of a differing call. A Python class extending a Java class has one Java super constructor, so the calls have to agree.
      Parameters:
      source - The source of the first call
      conflictingCall - The source of a call that differs
      Returns:
      The argument
    • isConflicting

      public boolean isConflicting()
      Returns:
      Whether another super().__init__(...) call of the constructor passes different arguments
    • isSpread

      public boolean isSpread()
      Returns:
      Whether the argument spreads the constructor's own *args or **kwargs into the call
    • isParameter

      public boolean isParameter()
      Returns:
      Whether the argument refers to a constructor parameter
    • isKeyword

      public boolean isKeyword()
      Returns:
      Whether the argument was passed by keyword
    • 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.
    • source

      public String source()
      Returns the value of the source record component.
      Returns:
      the value of the source record component
    • keyword

      @Nullable public @Nullable String keyword()
      Returns the value of the keyword record component.
      Returns:
      the value of the keyword record component
    • parameterName

      @Nullable public @Nullable String parameterName()
      Returns the value of the parameterName record component.
      Returns:
      the value of the parameterName record component
    • type

      @Nullable public @Nullable TypeRef type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • conflictingCall

      @Nullable public @Nullable String conflictingCall()
      Returns the value of the conflictingCall record component.
      Returns:
      the value of the conflictingCall record component