Record Class ColumnSpec
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 toOUTwhen omitted in sourcename- the column name as it appears in RA queries; must not be blanktype- the scalar type; must not be nullbinding- how the column maps to the transport; absent means the runtime uses the column name as the direct field or parameter namerequired-trueif a query must supply an equality predicate on this column; only meaningful forINcolumnsdefaultValue- a literal string default used when no predicate is provided andrequiredis false; only meaningful forINcolumns
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 Summary
ConstructorsConstructorDescriptionColumnSpec(ColumnDirection direction, String name, Type type, Optional<ColumnBinding> binding, boolean required, Optional<String> defaultValue) Creates an instance of aColumnSpecrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbinding()Returns the value of thebindingrecord component.Returns the value of thedefaultValuerecord component.Returns the value of thedirectionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.name()Returns the value of thenamerecord component.static ColumnSpecoptionalIn(String name, ScalarType type, String paramName, String defaultValue) Creates an optionalINcolumn with a default value.static ColumnSpecout(String name, ScalarType type) Creates a simpleOUTcolumn with no explicit binding.static ColumnSpecout(String name, ScalarType type, String path) Creates anOUTcolumn with an explicit JSONPath binding.booleanrequired()Returns the value of therequiredrecord component.static ColumnSpecrequiredIn(String name, ScalarType type, String paramName) Creates a requiredINcolumn bound to a URL query parameter.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
ColumnSpec
public ColumnSpec(ColumnDirection direction, String name, Type type, Optional<ColumnBinding> binding, boolean required, Optional<String> defaultValue) Creates an instance of aColumnSpecrecord class.- Parameters:
direction- the value for thedirectionrecord componentname- the value for thenamerecord componenttype- the value for thetyperecord componentbinding- the value for thebindingrecord componentrequired- the value for therequiredrecord componentdefaultValue- the value for thedefaultValuerecord component
-
-
Method Details
-
out
Creates a simpleOUTcolumn with no explicit binding.- Parameters:
name- the column nametype- the scalar type- Returns:
- a new spec
-
out
Creates anOUTcolumn with an explicit JSONPath binding.- Parameters:
name- the column nametype- the scalar typepath- the JSONPath expression- Returns:
- a new spec
-
requiredIn
Creates a requiredINcolumn bound to a URL query parameter.- Parameters:
name- the column nametype- the scalar typeparamName- the URL query-parameter name- Returns:
- a new spec
-
optionalIn
public static ColumnSpec optionalIn(String name, ScalarType type, String paramName, String defaultValue) Creates an optionalINcolumn with a default value.- Parameters:
name- the column nametype- the scalar typeparamName- the URL query-parameter namedefaultValue- the default literal value when no predicate is given- Returns:
- a new spec
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
direction
Returns the value of thedirectionrecord component.- Returns:
- the value of the
directionrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
type
Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-
binding
Returns the value of thebindingrecord component.- Returns:
- the value of the
bindingrecord component
-
required
public boolean required()Returns the value of therequiredrecord component.- Returns:
- the value of the
requiredrecord component
-
defaultValue
Returns the value of thedefaultValuerecord component.- Returns:
- the value of the
defaultValuerecord component
-