Class RecordTokenTypeBuilder


  • public class RecordTokenTypeBuilder
    extends Object
    An object for dynamically constructing a record type. Construction of a record type consists of defining its schema. Specifically, the Field objects comprising the schema must be collected. The order in which they are added is preserved, as it can be important (see RecordTokenType for more).

    When a record type is unknown until composition or execution time, this class is the preferred method for creating a descriptor for the type. For record types that can be statically defined, the factory methods in TokenTypeConstant are recommended instead.

    • Constructor Detail

      • RecordTokenTypeBuilder

        public RecordTokenTypeBuilder()
        Constructs a new record schema builder. The initial schema contains no Field entries.
      • RecordTokenTypeBuilder

        public RecordTokenTypeBuilder​(DataRepresentation representation)
        Constructs a new record schema builder where the specified representation format is used. The initial schema contains no Field entries.
        Parameters:
        representation - the format to use in the type being built
    • Method Detail

      • addField

        public void addField​(String name,
                             ScalarTokenType type)
        Adds a field with the specified name and type to this collection.
        Parameters:
        name - a name uniquely identifying the field within this collection
        type - the data type of the field
      • addField

        public void addField​(String name,
                             Field field)
        Adds a new field with the same type, domain, and properties as the original field but with a new name
        Parameters:
        name - the new name
        field - the field
      • addField

        public void addField​(String name,
                             ScalarTokenType type,
                             FieldDomain domain)
        Adds a field with the specified name and type to this collection.
        Parameters:
        name - a name uniquely identifying the field within this collection
        type - the data type of the field
        domain - the domain of the field
      • addField

        public void addField​(String name,
                             ScalarTokenType type,
                             Map<String,​String> properties,
                             FieldDomain domain,
                             boolean primaryKey)
        Adds a field with the specified name and type to this collection.
        Parameters:
        name - a name uniquely identifying the field within this collection
        type - the data type of the field
        properties - properties associated with this field
        domain - the domain of the field
        primaryKey - whether the values of the field must be unique
      • addField

        public void addField​(Field field)
        Adds the specified field to this collection.
        Parameters:
        field - the field to add to the schema. The field name must differ from that of any existing field in the schema.
      • toType

        public RecordTokenType toType()
        Gets the record schema currently defined by this collection.
        Returns:
        an immutable copy of the schema