java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.source.ColumnSpec
Record Components:
direction - whether the column is pushed into the request (IN) or extracted from the response (OUT); defaults to OUT when omitted in source
name - the column name as it appears in RA queries; must not be blank
type - the scalar type; must not be null
binding - how the column maps to the transport; absent means the runtime uses the column name as the direct field or parameter name
required - true if a query must supply an equality predicate on this column; only meaningful for IN columns
defaultValue - a literal string default used when no predicate is provided and required is false; only meaningful for IN columns

public record ColumnSpec(ColumnDirection direction, String name, Type type, Optional<ColumnBinding> binding, boolean required, Optional<String> defaultValue) extends Record
Describes one column in a source declaration's schema.

Full syntax examples:

   city:  in  STRING as query("q")          [required]
   units: in  STRING as query("units")       [default: "metric"]
   temp:  out NUMBER at "$.main.temp"
   name:  out STRING                          // binding inferred from column name
 
  • Constructor Details

    • ColumnSpec

      public ColumnSpec(ColumnDirection direction, String name, Type type, Optional<ColumnBinding> binding, boolean required, Optional<String> defaultValue)
      Creates an instance of a ColumnSpec record class.
      Parameters:
      direction - the value for the direction record component
      name - the value for the name record component
      type - the value for the type record component
      binding - the value for the binding record component
      required - the value for the required record component
      defaultValue - the value for the defaultValue record component
  • Method Details

    • out

      public static ColumnSpec out(String name, ScalarType type)
      Creates a simple OUT column with no explicit binding.
      Parameters:
      name - the column name
      type - the scalar type
      Returns:
      a new spec
    • out

      public static ColumnSpec out(String name, ScalarType type, String path)
      Creates an OUT column with an explicit JSONPath binding.
      Parameters:
      name - the column name
      type - the scalar type
      path - the JSONPath expression
      Returns:
      a new spec
    • requiredIn

      public static ColumnSpec requiredIn(String name, ScalarType type, String paramName)
      Creates a required IN column bound to a URL query parameter.
      Parameters:
      name - the column name
      type - the scalar type
      paramName - the URL query-parameter name
      Returns:
      a new spec
    • optionalIn

      public static ColumnSpec optionalIn(String name, ScalarType type, String paramName, String defaultValue)
      Creates an optional IN column with a default value.
      Parameters:
      name - the column name
      type - the scalar type
      paramName - the URL query-parameter name
      defaultValue - the default literal value when no predicate is given
      Returns:
      a new spec
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • direction

      public ColumnDirection direction()
      Returns the value of the direction record component.
      Returns:
      the value of the direction record component
    • name

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

      public Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • binding

      public Optional<ColumnBinding> binding()
      Returns the value of the binding record component.
      Returns:
      the value of the binding record component
    • required

      public boolean required()
      Returns the value of the required record component.
      Returns:
      the value of the required record component
    • defaultValue

      public Optional<String> defaultValue()
      Returns the value of the defaultValue record component.
      Returns:
      the value of the defaultValue record component