Package io.permazen.core
Class Field<T>
java.lang.Object
io.permazen.core.SchemaItem
io.permazen.core.Field<T>
- Type Parameters:
T
- field's value type
- Direct Known Subclasses:
ComplexField
,CounterField
,SimpleField
-
Method Summary
Modifier and TypeMethodDescriptionGet the full name of this field.byte[]
Get thebyte[]
key in the underlying key/value store corresponding to this field in the specified object.Get theObjType
that contains this field.Get the Java type corresponding to this field.abstract T
getValue
(Transaction tx, ObjId id) Get the value of this field in the given object.abstract boolean
hasDefaultValue
(Transaction tx, ObjId id) Determine if this field in the specified object has its default value in the specifiedTransaction
.abstract <R> R
visit
(FieldSwitch<R> target) Apply visitor pattern.Methods inherited from class io.permazen.core.SchemaItem
getName, getSchema, getSchemaId, getStorageId, toString
-
Method Details
-
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
Get theObjType
that contains this field.- Returns:
- this field's object type
-
getTypeToken
Get the Java type corresponding to this field.- Returns:
- this field's type
-
getValue
Get the value of this field in the given object. Does not alter the schema of the object.- Parameters:
tx
- transactionid
- object id- Returns:
- this field's value in the specified object
- Throws:
DeletedObjectException
- if no object with ID equal toid
is foundUnknownTypeException
- ifid
specifies an unknown object typeUnknownFieldException
- if this field does not exist in the specified objectStaleTransactionException
- if this transaction is no longer usableIllegalArgumentException
- if either parameter is nullIllegalArgumentException
- if this field is a sub-field of aComplexField
-
hasDefaultValue
Determine if this field in the specified object has its default value in the specifiedTransaction
.- Parameters:
tx
-Transaction
containing field stateid
- 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 toid
is foundUnknownTypeException
- ifid
specifies an unknown object typeStaleTransactionException
- if this transaction is no longer usableIllegalArgumentException
- if either parameter is nullIllegalArgumentException
- if this field is a sub-field of aComplexField
-
getKey
Get thebyte[]
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
- ifid
is null or has the wrong object type- See Also:
-
visit
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
- iftarget
is null
-