Package oracle.kv.table
Interface FieldDef
- All Known Subinterfaces:
AnyAtomicDef
,AnyDef
,AnyJsonAtomicDef
,AnyRecordDef
,ArrayDef
,BinaryDef
,BooleanDef
,DoubleDef
,EnumDef
,FixedBinaryDef
,FloatDef
,IntegerDef
,JsonDef
,LongDef
,MapDef
,NumberDef
,RecordDef
,StringDef
,TimestampDef
public interface FieldDef
FieldDef represents an immutable metadata object used to represent a single
data type. A data type defines a set of values, which are said to belong to
or be instances of that data type. Data types are either atomic or
complex. Atomic types define sets of atomic values, like integers,
doubles, strings, etc. Complex types represent complex values, i.e., values
that contain other (nested) values, like records, arrays, and maps.
All supported data types are represented as instances of FieldDef.
Supported types are defined in the enumeration Type
.
Instances of FieldDef are created when defining the fields for a new
Table
, or during query processing.
Each instance has these properties:
- type -- the kind of the type (one of the values of the
FieldDef.Type
enum. - description -- an optional description used when defining the type.
- Since:
- 3.0
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionasAny()
Casts to AnyDef.Casts to AnyAtomicDef.Casts to AnyJsonAtomicDef.Casts to AnyRecordDef.asArray()
Casts to ArrayDef.asBinary()
Casts to BinaryDef.Casts to BooleanDef.asDouble()
Casts to DoubleDef.asEnum()
Casts to EnumDef.Casts to FixedBinaryDef.asFloat()
Casts to FloatDef.Casts to IntegerDef.asJson()
Casts to JsonDef.asLong()
Casts to LongDef.asMap()
Casts to MapDef.asNumber()
Casts to NumberDef.asRecord()
Casts to RecordDef.asString()
Casts to StringDef.Casts to TimestampDef.clone()
Perform a deep copy of this FieldDef instance.Creates an empty ArrayValue.createBinary
(byte[] value) Creates a BinaryValue instance based on the value.createBoolean
(boolean value) Creates a BooleanValue instance based on the value.createDouble
(double value) Creates a DoubleValue instance based on the value.createEnum
(String value) Creates an EnumValue instance based on the value.createFixedBinary
(byte[] value) Creates a FixedBinaryValue instance based on the value.createFloat
(float value) Creates a FloatValue instance based on the value.createInteger
(int value) Creates an IntegerValue instance based on the value.Creates a special FieldValue instance representing a JSON null.createLong
(long value) Creates a LongValue instance based on the value.Creates an empty MapValue.createNumber
(double value) Creates a NumberValue instance based on the valuecreateNumber
(float value) Creates a NumberValue instance based on the valuecreateNumber
(int value) Creates a NumberValue instance based on the valuecreateNumber
(long value) Creates a NumberValue instance based on the valuecreateNumber
(BigDecimal value) Creates a NumberValue instance based on the valueCreates an empty RecordValue.createString
(String value) Creates a StringValue instance based on the value.createTimestamp
(Timestamp value) Creates a TimestampValue instance based on the value.Returns the description of the field.getType()
Returns the type of the field.boolean
isAny()
Returns true if this is anAnyDef
.boolean
Returns true if this is anAnyAtomicDef
.boolean
Returns true if this is anAnyJsonAtomicDef
.boolean
Returns true if this is anAnyRecordDef
.boolean
isArray()
Returns true if this is anArrayDef
.boolean
isAtomic()
Returns true if this is an atomic type.boolean
isBinary()
Returns true if this is aBinaryDef
.boolean
Returns true if this is aBooleanDef
.boolean
Returns true if this is a complex type.boolean
isDouble()
Returns true if this is aDoubleDef
.boolean
isEnum()
Returns true if this is anEnumDef
.boolean
Returns true if this is aFixedBinaryDef
.boolean
isFloat()
Returns true if this is aFloatDef
.boolean
Returns true if this is anIntegerDef
.boolean
isJson()
Returns true if this is a JSON type.boolean
isLong()
Returns true if this is aLongDef
.boolean
isMap()
Returns true if this is aMapDef
.default boolean
Returns true if this is a multi-region counter.boolean
isNumber()
Returns true if this is aNumberDef
.boolean
Returns true if this is a numeric type.boolean
boolean
isRecord()
Returns true if this is aRecordDef
.boolean
isString()
Returns true if this is aStringDef
.boolean
Returns true if this is aTimestampDef
.boolean
isType
(FieldDef.Type type) Returns true if the type of this field matches the parameter.boolean
Returns true if this is a STRING AS UUID typeboolean
boolean
-
Method Details
-
clone
FieldDef clone()Perform a deep copy of this FieldDef instance.- Returns:
- a new instance equal to this
-
getDescription
String getDescription()Returns the description of the field.- Returns:
- the description of the field if set, otherwise null
-
getType
FieldDef.Type getType()Returns the type of the field.- Returns:
- the type of the field
-
isType
Returns true if the type of this field matches the parameter.- Returns:
- true if the type of this field matches the parameter
-
isValidKeyField
boolean isValidKeyField()- Returns:
- true if this type can participate in a primary key. Only atomic types can be part of a key. Among the atomic types, Boolean, Binary and FixedBinary are not allowed in keys.
-
isValidIndexField
boolean isValidIndexField()- Returns:
- true if this type can participate in an index. Only atomic types can be part of an index key. Among the atomic types, Boolean, Binary and FixedBinary are not allowed in index keys.
-
isAny
boolean isAny()Returns true if this is anAnyDef
.- Returns:
- true if this is an AnyDef, false otherwise
- Since:
- 4.0
-
isAnyRecord
boolean isAnyRecord()Returns true if this is anAnyRecordDef
.- Returns:
- true if this is an AnyRecordDef, false otherwise
- Since:
- 4.0
-
isAnyAtomic
boolean isAnyAtomic()Returns true if this is anAnyAtomicDef
.- Returns:
- true if this is an AnyAtomicDef, false otherwise
- Since:
- 4.0
-
isNumber
boolean isNumber()Returns true if this is aNumberDef
.- Returns:
- true if this is a NumberDef, false otherwise
- Since:
- 4.4
-
isAnyJsonAtomic
boolean isAnyJsonAtomic()Returns true if this is anAnyJsonAtomicDef
.- Returns:
- true if this is an AnyJsonAtomicDef, false otherwise
- Since:
- 4.3
-
isBoolean
boolean isBoolean()Returns true if this is aBooleanDef
.- Returns:
- true if this is a BooleanDef, false otherwise
-
isBinary
boolean isBinary()Returns true if this is aBinaryDef
.- Returns:
- true if this is a BinaryDef, false otherwise
-
isDouble
boolean isDouble()Returns true if this is aDoubleDef
.- Returns:
- true if this is a DoubleDef, false otherwise
-
isEnum
boolean isEnum()Returns true if this is anEnumDef
.- Returns:
- true if this is an EnumDef, false otherwise
-
isFixedBinary
boolean isFixedBinary()Returns true if this is aFixedBinaryDef
.- Returns:
- true if this is a FixedBinaryDef, false otherwise
-
isFloat
boolean isFloat()Returns true if this is aFloatDef
.- Returns:
- true if this is a FloatDef, false otherwise
-
isInteger
boolean isInteger()Returns true if this is anIntegerDef
.- Returns:
- true if this is an IntegerDef, false otherwise
-
isLong
boolean isLong()Returns true if this is aLongDef
.- Returns:
- true if this is a LongDef, false otherwise
-
isString
boolean isString()Returns true if this is aStringDef
.- Returns:
- true if this is a StringDef, false otherwise
-
isUUIDString
boolean isUUIDString()Returns true if this is a STRING AS UUID type- Returns:
- true if this is a STRING AS UUID type, false otherwise
-
isTimestamp
boolean isTimestamp()Returns true if this is aTimestampDef
.- Returns:
- true if this is a TimestampDef, false otherwise
- Since:
- 4.3
-
isArray
boolean isArray()Returns true if this is anArrayDef
.- Returns:
- true if this is an ArrayDef, false otherwise
-
isMap
boolean isMap()Returns true if this is aMapDef
.- Returns:
- true if this is a MapDef, false otherwise
-
isRecord
boolean isRecord()Returns true if this is aRecordDef
.- Returns:
- true if this is a RecordDef, false otherwise
-
isJson
boolean isJson()Returns true if this is a JSON type.- Returns:
- true if this is a JSON type, false otherwise
- Since:
- 4.2
-
isAtomic
boolean isAtomic()Returns true if this is an atomic type.- Returns:
- true if this is an atomic type, false otherwise
- Since:
- 4.0
-
isNumeric
boolean isNumeric()Returns true if this is a numeric type.- Returns:
- true if this is a numeric type, false otherwise
- Since:
- 4.0
-
isComplex
boolean isComplex()Returns true if this is a complex type.- Returns:
- true if this is a complex type, false otherwise
- Since:
- 4.0
-
isPrecise
boolean isPrecise()- Since:
- 20.1
-
isMRCounter
default boolean isMRCounter()Returns true if this is a multi-region counter.- Returns:
- true if this is a multi-region counter, false otherwise.
- Since:
- 21.1
-
asAny
AnyDef asAny()Casts to AnyDef.- Returns:
- an AnyDef
- Throws:
ClassCastException
- if this is not an AnyDef- Since:
- 4.0
-
asAnyRecord
AnyRecordDef asAnyRecord()Casts to AnyRecordDef.- Returns:
- an AnyRecordDef
- Throws:
ClassCastException
- if this is not an AnyRecordDef- Since:
- 4.0
-
asAnyAtomic
AnyAtomicDef asAnyAtomic()Casts to AnyAtomicDef.- Returns:
- an AnyAtomicDef
- Throws:
ClassCastException
- if this is not an AnyAtomicDef- Since:
- 4.0
-
asAnyJsonAtomic
AnyJsonAtomicDef asAnyJsonAtomic()Casts to AnyJsonAtomicDef.- Returns:
- an AnyJsonAtomicDef
- Throws:
ClassCastException
- if this is not an AnyJsonAtomicDef- Since:
- 4.3
-
asBinary
BinaryDef asBinary()Casts to BinaryDef.- Returns:
- a BinaryDef
- Throws:
ClassCastException
- if this is not a BinaryDef
-
asNumber
NumberDef asNumber()Casts to NumberDef.- Returns:
- a NumberDef
- Throws:
ClassCastException
- if this is not a NumberDef- Since:
- 4.4
-
asBoolean
BooleanDef asBoolean()Casts to BooleanDef.- Returns:
- a BooleanDef
- Throws:
ClassCastException
- if this is not a BooleanDef
-
asDouble
DoubleDef asDouble()Casts to DoubleDef.- Returns:
- a DoubleDef
- Throws:
ClassCastException
- if this is not a DoubleDef
-
asEnum
EnumDef asEnum()Casts to EnumDef.- Returns:
- an EnumDef
- Throws:
ClassCastException
- if this is not an EnumDef
-
asFixedBinary
FixedBinaryDef asFixedBinary()Casts to FixedBinaryDef.- Returns:
- a FixedBinaryDef
- Throws:
ClassCastException
- if this is not a FixedBinaryDef
-
asFloat
FloatDef asFloat()Casts to FloatDef.- Returns:
- a FloatDef
- Throws:
ClassCastException
- if this is not a FloatDef
-
asInteger
IntegerDef asInteger()Casts to IntegerDef.- Returns:
- an IntegerDef
- Throws:
ClassCastException
- if this is not an IntegerDef
-
asLong
LongDef asLong()Casts to LongDef.- Returns:
- a LongDef
- Throws:
ClassCastException
- if this is not a LongDef
-
asString
StringDef asString()Casts to StringDef.- Returns:
- a StringDef
- Throws:
ClassCastException
- if this is not a StringDef
-
asTimestamp
TimestampDef asTimestamp()Casts to TimestampDef.- Returns:
- a TimestampDef
- Throws:
ClassCastException
- if this is not a TimestampDef- Since:
- 4.3
-
asArray
ArrayDef asArray()Casts to ArrayDef.- Returns:
- an ArrayDef
- Throws:
ClassCastException
- if this is not an ArrayDef
-
asMap
MapDef asMap()Casts to MapDef.- Returns:
- a MapDef
- Throws:
ClassCastException
- if this is not a MapDef
-
asRecord
RecordDef asRecord()Casts to RecordDef.- Returns:
- a RecordDef
- Throws:
ClassCastException
- if this is not a RecordDef
-
asJson
JsonDef asJson()Casts to JsonDef.- Returns:
- a JsonDef
- Throws:
ClassCastException
- if this is not a JsonDef- Since:
- 4.2
-
createArray
ArrayValue createArray()Creates an empty ArrayValue.- Returns:
- an empty ArrayValue
- Throws:
IllegalArgumentException
- if this instance is not able to create an ArrayValue
-
createNumber
Creates a NumberValue instance based on the value- Parameters:
value
- the value to use- Returns:
- a NumberValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a NumberValue- Since:
- 4.4
-
createNumber
Creates a NumberValue instance based on the value- Parameters:
value
- the value to use- Returns:
- a NumberValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a NumberValue- Since:
- 4.4
-
createNumber
Creates a NumberValue instance based on the value- Parameters:
value
- the value to use- Returns:
- a NumberValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a NumberValue- Since:
- 4.4
-
createNumber
Creates a NumberValue instance based on the value- Parameters:
value
- the value to use- Returns:
- a NumberValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a NumberValue- Since:
- 4.4
-
createNumber
Creates a NumberValue instance based on the value- Parameters:
value
- a non-null BigDecimal value- Returns:
- a NumberValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a NumberValue- Since:
- 4.4
-
createBinary
Creates a BinaryValue instance based on the value.- Parameters:
value
- the byte array to use for the new value object. Must not be null.- Returns:
- a BinaryValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a BinaryValue or if the value is null
-
createBoolean
Creates a BooleanValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a BooleanValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a BooleanValue
-
createDouble
Creates a DoubleValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a DoubleValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a DoubleValue
-
createEnum
Creates an EnumValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a EnumValue
- Throws:
IllegalArgumentException
- if this instance is not able to create an EnumValue or if the value is not valid for the definition
-
createFixedBinary
Creates a FixedBinaryValue instance based on the value.- Parameters:
value
- the value to use. It must not be null.- Returns:
- a FixedBinaryValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a FixedBinaryValue or if the value is null or not valid for the definition
-
createFloat
Creates a FloatValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a FloatValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a FloatValue
-
createInteger
Creates an IntegerValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a IntegerValue
- Throws:
IllegalArgumentException
- if this instance is not able to create an IntegerValue or if the value is not valid for the definition
-
createLong
Creates a LongValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a LongValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a LongValue
-
createTimestamp
Creates a TimestampValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a TimestampValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a TimestampValue- Since:
- 4.3
-
createMap
MapValue createMap()Creates an empty MapValue.- Returns:
- an empty MapValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a MapValue
-
createRecord
RecordValue createRecord()Creates an empty RecordValue.- Returns:
- an empty RecordValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a RecordValue
-
createString
Creates a StringValue instance based on the value.- Parameters:
value
- the value to use- Returns:
- a StringValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a StringValue
-
createJsonNull
FieldValue createJsonNull()Creates a special FieldValue instance representing a JSON null. This value returns true forFieldValue.isJsonNull()
.- Returns:
- a FieldValue
- Throws:
IllegalArgumentException
- if this instance is not able to create a JSON null (is not of type JSON)- Since:
- 4.3
-