Record Class StructType

java.lang.Object
java.lang.Record
com.darkcollective.relix.symbol.StructType
Record Components:
fields - the ordered fields; never null, copied defensively
All Implemented Interfaces:
Type

public record StructType(List<StructType.Field> fields) extends Record implements Type
A nested struct type — an ordered set of named, typed StructType.Fields.

A struct is how relix represents a nested object (a JSON object, a Mongo sub-document). Conceptually a Schema is the top-level struct of a row, so the flat relational model is the special case where every field is a ScalarType.

Field names are case-preserved but must be unique case-insensitively, and field(String) looks them up case-insensitively — matching Schema.

  • Constructor Details

    • StructType

      public StructType(List<StructType.Field> fields)
      Creates an instance of a StructType record class.
      Parameters:
      fields - the value for the fields record component
  • Method Details

    • field

      public Optional<StructType.Field> field(String name)
      Returns the field named name, matched case-insensitively.
      Parameters:
      name - the field name to look up
      Returns:
      the matching field, or empty if none
    • display

      public String display()
      Description copied from interface: Type
      A short, human-readable, structurally-recursive description of this type — e.g. "number", "struct{id: number, tags: array<string>}", "array<number>".
      Specified by:
      display in interface Type
      Returns:
      the display string; never null or blank
    • code

      public String code()
      Description copied from interface: Type
      A compact, structurally-recursive type code used in the IR report and in machine-readable (JSON) output. Scalars are one letter (Number, String, Boolean, ?=any); an array is [elem] and a struct is {field:code,…} — e.g. [N], {id:N,tags:[S]}.
      Specified by:
      code in interface Type
      Returns:
      the compact type code; never null or blank
    • 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.
    • fields

      public List<StructType.Field> fields()
      Returns the value of the fields record component.
      Returns:
      the value of the fields record component