Record Class ParameterDefinition

java.lang.Object
java.lang.Record
com.darkcollective.relix.symbol.ParameterDefinition
Record Components:
name - the parameter name as declared; must not be blank
type - the scalar type of this parameter; ScalarType.ANY for a relation parameter; must not be null
heading - the columns of a relation parameter; empty for a scalar one; must not be null

public record ParameterDefinition(String name, ScalarType type, Optional<Schema> heading) extends Record
A single parameter in a function signature: a scalar, or — for a table-valued function only — a relation.

A scalar parameter has a type() and no heading(). A relation parameter (E: RELATION(src, dst)) has a heading — the columns the function body may read from it, each with a type or ScalarType.ANY — and reports ScalarType.ANY as its type, so that FunctionSymbol.parameterSignature() stays a list of scalar types. A relation argument is a relation's name; the body sees it narrowed to the heading.

Parameter names are used only for documentation and error messages; overload resolution is based solely on the ordered list of type() values (the parameter signature).

  • Constructor Details

    • ParameterDefinition

      public ParameterDefinition(String name, ScalarType type, Optional<Schema> heading)
      Creates an instance of a ParameterDefinition record class.
      Parameters:
      name - the value for the name record component
      type - the value for the type record component
      heading - the value for the heading record component
    • ParameterDefinition

      public ParameterDefinition(String name, ScalarType type)
      A scalar parameter.
      Parameters:
      name - the parameter name; must not be blank
      type - its scalar type; must not be null
  • Method Details

    • relation

      public static ParameterDefinition relation(String name, Schema heading)
      A relation parameter — name: RELATION(columns…).
      Parameters:
      name - the parameter name; must not be blank
      heading - the columns the body may read; closed, and at least one
      Returns:
      the parameter
    • isRelation

      public boolean isRelation()
      Returns whether this is a relation parameter.
      Returns:
      whether this is a relation parameter
    • 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.
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • type

      public ScalarType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • heading

      public Optional<Schema> heading()
      Returns the value of the heading record component.
      Returns:
      the value of the heading record component