Class RecordToken

All Implemented Interfaces:
DataToken, RecordValued, TokenValued, RecordTyped, TokenTyped, Serializable, Comparable<RecordToken>

public final class RecordToken extends AbstractRecordValued<ScalarToken> implements DataToken, Comparable<RecordToken>
A composite token of scalar valued tokens; an immutable RecordValued object. A RecordToken can also be thought of as a row of tabular data.
See Also:
  • Constructor Details

    • RecordToken

      public RecordToken(RecordValued value)
      Constructs a new token with the composite value in the given container. The resulting token has the same schema as the value.
      Parameters:
      value - a RecordValued containing the desired value
    • RecordToken

      public RecordToken(ScalarValued... fieldValues)
      Constructs a new token using the field values in the given containers. A record type with default names will be generated for the token.
      Parameters:
      fieldValues - the values for the fields of the composite token.
    • RecordToken

      public RecordToken(RecordTokenType type, ScalarValued... fieldValues)
      Constructs a new token with the specified field types, using the field values in the given containers.

      The list of scalar values are expected in the same order as the fields in the provided type.

      Parameters:
      type - the schema of the composite token
      fieldValues - the values for the fields of the composite token.
  • Method Details

    • NULL

      public static RecordToken NULL(RecordTokenType recordType)
      Create a new null valued record token of the specified type. All fields will be null valued.
      Parameters:
      recordType - the record token type of the token to create
      Returns:
      a null valued record token
    • ZERO

      public static RecordToken ZERO(RecordTokenType recordType)
      Create a new zero valued record token of the specified type. All fields will be zero valued.
      Parameters:
      recordType - the record token type of the token to create
      Returns:
      a zero valued record token
    • compareTo

      public int compareTo(RecordToken that)
      Specified by:
      compareTo in interface Comparable<RecordToken>
    • equals

      public boolean equals(Object obj)
      Description copied from interface: DataToken
      Indicates whether another object is equal to this token. Two null valued tokens are considered equal. This differs from the behavior of TokenComparator.equal(TokenValued,TokenValued) but makes it possible to store DataTokens in Maps.
      Specified by:
      equals in interface DataToken
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare
      Returns:
      true if the other object is a token of the same type and contains the same value, false otherwise.
    • hashCode

      public int hashCode()
      Description copied from interface: DataToken
      Returns a hash code for the token. This value is guaranteed to be consistent with that returned by TokenConverter.asHashCode(TokenValued).
      Specified by:
      hashCode in interface DataToken
      Overrides:
      hashCode in class Object
      Returns:
      a hash code value for the token
    • wrap

      public static RecordToken wrap(String name, ScalarValued value)
      Create a new record token with a single field with the specified name and value.
      Parameters:
      name - the name of the single field in the result
      value - the value of the single field in the result
      Returns:
      the resulting token