Class Field<T>

Type Parameters:
T - field's value type
Direct Known Subclasses:
ComplexField, CounterField, SimpleField

public abstract class Field<T> extends SchemaItem
A field in an ObjType or a (simple) sub-field of a ComplexField in an ObjType.
  • Method Details

    • getFullName

      public String getFullName()
      Get the full name of this field.

      If the field is a sub-field of a complex field, the full name is the field's name qualified by the parent field name, e.g., "mymap.key". Otherwise, the full is is the same as the name.

      Returns:
      this field's full name
    • getObjType

      public ObjType getObjType()
      Get the ObjType that contains this field.
      Returns:
      this field's object type
    • getTypeToken

      public TypeToken<T> getTypeToken()
      Get the Java type corresponding to this field.
      Returns:
      this field's type
    • getValue

      public abstract T getValue(Transaction tx, ObjId id)
      Get the value of this field in the given object. Does not alter the schema of the object.
      Parameters:
      tx - transaction
      id - object id
      Returns:
      this field's value in the specified object
      Throws:
      DeletedObjectException - if no object with ID equal to id is found
      UnknownTypeException - if id specifies an unknown object type
      UnknownFieldException - if this field does not exist in the specified object
      StaleTransactionException - if this transaction is no longer usable
      IllegalArgumentException - if either parameter is null
      IllegalArgumentException - if this field is a sub-field of a ComplexField
    • hasDefaultValue

      public abstract boolean hasDefaultValue(Transaction tx, ObjId id)
      Determine if this field in the specified object has its default value in the specified Transaction.
      Parameters:
      tx - Transaction containing field state
      id - object ID
      Returns:
      true if this field is set to its initial default value in object id, otherwise false
      Throws:
      DeletedObjectException - if no object with ID equal to id is found
      UnknownTypeException - if id specifies an unknown object type
      StaleTransactionException - if this transaction is no longer usable
      IllegalArgumentException - if either parameter is null
      IllegalArgumentException - if this field is a sub-field of a ComplexField
    • getKey

      public byte[] getKey(ObjId id)
      Get the byte[] key in the underlying key/value store corresponding to this field in the specified object.

      Notes:

      • This method does not check whether the object actually exists.
      • Complex fields utilize multiple keys; the return value is the common prefix of all such keys.
      • The KVDatabase should not be modified directly, otherwise behavior is undefined
      Parameters:
      id - object ID
      Returns:
      the KVDatabase key (or key prefix) for the field in the specified object
      Throws:
      IllegalArgumentException - if id is null or has the wrong object type
      See Also:
    • visit

      public abstract <R> R visit(FieldSwitch<R> target)
      Apply visitor pattern.
      Type Parameters:
      R - visitor return type
      Parameters:
      target - target to invoke
      Returns:
      return value from the method of target corresponding to this instance's type
      Throws:
      NullPointerException - if target is null