Interface RecordDef

All Superinterfaces:
FieldDef

public interface RecordDef extends FieldDef
RecordDef represents a record type, which specifies a set of RecordValues that conform to this type. The type definition declares a number of fields, where a field consists of a name and an associated type. The field types need not be the same. The declaration order of the fields is important. Based on this order, each field has a unique position, which is a number between 0 and N - 1, where N is the number of fields. In addition to its name, type, and position, each field may be declared nullable or non-nullable (with the default being nullable), and may have an associated default value. The default value is required for non-nullable fields; otherwise, the default default-value is the NULL value (an instance of FieldValue for which the isNull() method returns true). A RecordValue conforms to a record type if (a) it has the same number of fields as the type, (b) the fields in the record value and the record type have the same names and appear in the same order, and (c) the field values in the record have the same type as the type of the corresponding fields in the record type.
Since:
3.0
  • Method Details

    • getNumFields

      int getNumFields()
      Get the number of fields declared by this record type.
      Returns:
      the number of fields declared by this record type
      Since:
      4.2
    • getFields

      @Deprecated List<String> getFields()
      Deprecated.
      as of 4.2 Use getFieldNames()
      Get the names of the fields declared by this record type. The names are returned in declaration order.
      Returns:
      an unmodifiable list of the field names in declaration order
    • getFieldNames

      List<String> getFieldNames()
      Get the names of the fields declared by this record type. The names are returned in declaration order.
      Returns:
      an unmodifiable list of the field names in declaration order
      Since:
      4.2
    • contains

      boolean contains(String name)
      Returns true if the record tyoe contains a field with the given name
      Returns:
      true if the record tyoe contains a field with the given name, false otherwise
    • getField

      @Deprecated FieldDef getField(String name)
      Deprecated.
      as of 4.2 Use getFieldDef(String)
      Get the type of the field with the given name.
      Parameters:
      name - the name of the field
      Returns:
      the type of the field with the given name, or null if there is no field with such a name
    • getFieldDef

      FieldDef getFieldDef(String name)
      Get the type of the field with the given name.
      Parameters:
      name - the name of the field
      Returns:
      the type of the field with the given name, or null if there is no field with such a name
      Since:
      4.2
    • getField

      @Deprecated FieldDef getField(int pos)
      Deprecated.
      as of 4.2 Use getFieldDef(int)
      Get the type of the field at the given position.
      Parameters:
      pos - the index in the list of fields of the field to return
      Returns:
      the type of the field at the specified position.
      Throws:
      IndexOutOfBoundsException - if the position is negative or greater or equal to the number of fields declared by this record type.
      Since:
      4.0
    • getFieldDef

      FieldDef getFieldDef(int pos)
      Get the type of the field at the given position.
      Parameters:
      pos - the position of the field in the list of fields
      Returns:
      the type of the field at the specified position.
      Throws:
      IndexOutOfBoundsException - if the position is negative or greater or equal to the number of fields declared by this record type.
      Since:
      4.2
    • getFieldName

      String getFieldName(int pos)
      Get the name of the field at the given position.
      Parameters:
      pos - the position of the field in the list of fields
      Returns:
      the name of the field at the given position.
      Throws:
      IndexOutOfBoundsException - if the position is negative or greater or equal to the number of fields declared by this record type.
      Since:
      4.0
    • getFieldPos

      int getFieldPos(String fname)
      Returns the position of the field with the given name
      Returns:
      the position of the field with the given name.
      Throws:
      IllegalArgumentException - if there is no field with the given name
      Since:
      4.2
    • getName

      String getName()
      Get the name of the record type. Record types require names even if they are nested or used as an array or map element.
      Returns:
      the name of the record type
    • isNullable

      boolean isNullable(String name)
      Returns true if the named field is nullable.
      Parameters:
      name - the name of the field
      Returns:
      true if the named field is nullable
      Throws:
      IllegalArgumentException - if there is no field with the given name
    • isNullable

      boolean isNullable(int pos)
      Returns true if the field at the given position is nullable.
      Parameters:
      pos - the position of the field in the list of fields
      Returns:
      true if the named field is nullable
      Throws:
      IndexOutOfBoundsException - if the position is negative or greater or equal to the number of fields declared by this record type.
      Since:
      4.2
    • getDefaultValue

      FieldValue getDefaultValue(String name)
      Returns the default value for the named field. The return value is FieldValue and not a more specific type because in the case of nullable fields the default will be a null value, which is a special value that returns true for isNullable(java.lang.String).
      Parameters:
      name - the name of the field
      Returns:
      a default value
      Throws:
      IllegalArgumentException - if there is no field with the given name
    • getDefaultValue

      FieldValue getDefaultValue(int pos)
      Returns the default value for the field at the given position. The return value is FieldValue and not a more specific type because in the case of nullable fields the default will be a null value, which is a special value that returns true for isNullable(java.lang.String).
      Parameters:
      pos - the position of the field in the list of fields
      Returns:
      a default value
      Throws:
      IndexOutOfBoundsException - if the position is negative or greater or equal to the number of fields declared by this record type.
      Since:
      4.2
    • clone

      RecordDef clone()
      Description copied from interface: FieldDef
      Perform a deep copy of this FieldDef instance.
      Specified by:
      clone in interface FieldDef
      Returns:
      a deep copy of this object