Package tech.ydb.yoj.databind
Enum Class FieldValueType
- All Implemented Interfaces:
Serializable,Comparable<FieldValueType>,Constable
Field value type for data binding.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionDeprecated, for removal: This API element is subject to removal in a future version.Boolean value.Binary value: just a stream of uninterpreted bytes.Composite value.Enum value.Integer value.Interval.Polymorphic object stored in an opaque form (i.e., individual fields cannot be accessed by data binding).
Serialized form strongly depends on the the marshalling mechanism (e.g., JSON, YAML, ...).Real (floating-point) number value.String value.Timestamp.Universally Unique Identitifer (UUID). -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldValueTypeforJavaType(@NonNull Type type, @NonNull ReflectField reflectField) Detects the data binding type appropriate for the specified Java value type that will be used with the specified Schema field.static FieldValueTypeforJavaType(@NonNull Type type, Column columnAnnotation, CustomValueTypeInfo<?, ?> cvt) Detects the data binding type appropriate for the specified Java value type, provided that we know the@Columnannotation value as well as custom value type information.static FieldValueTypeforSchemaField(@NonNull Schema.JavaField schemaField) Detects the data binding type appropriate for the specified Schema field.booleanstatic FieldValueTypeReturns the enum constant of this class with the specified name.static FieldValueType[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
INTEGER
Integer value. Java-side must be along,int,shortorbyte, or an instance of their wrapper classesLong,Integer,ShortorByte. -
REAL
Real (floating-point) number value. Java-side must be adoubleor afloat, or an instance of their wrapper classesDoubleorFloat. -
STRING
String value. Java-side must be aString. -
BOOLEAN
Boolean value. Java-side must either be abooleanprimitive, or an instance of its wrapper classBoolean. -
ENUM
Enum value. Java-side must be a concrete subclass ofjava.lang.Enum. -
TIMESTAMP
Timestamp. Java-side must be an instance ofjava.time.Instant. -
INTERVAL
Interval. Java-side must be an instance ofjava.time.Duration. -
UUID
Universally Unique Identitifer (UUID). Java-side must be an instance ofUUID. -
BINARY
Deprecated, for removal: This API element is subject to removal in a future version.Support for mapping rawbyte[]will be removed in YOJ 3.0.0. Even now, it is strongly recommended to use aByteArray: it is properlyComparableand has a saneequals(), which ensures that queries will work the same in both in-memory database and YDB.Binary value: just a stream of uninterpreted bytes. Java-side must be abyte[]. -
BYTE_ARRAY
Binary value: just a stream of uninterpreted bytes. Java-side must be atech.ydb.yoj.databind.ByteArray. -
COMPOSITE
Composite value. Can contain any other values, including other composite values.
Java-side must be an immutable value reflectable by YOJ: a JavaRecord, a Kotlindata class, an immutable POJO with all-args constructor annotated with@ConstructorPropertiesetc. -
OBJECT
Polymorphic object stored in an opaque form (i.e., individual fields cannot be accessed by data binding).
Serialized form strongly depends on the the marshalling mechanism (e.g., JSON, YAML, ...).To marshal
OBJECTvalues using YOJ, you must configure aJsonConverterby callingCommonConverter.defineJsonConverter()(inyoj-repositorymodule). YOJ offers a reasonably configured Jackson-basedJacksonJsonConverterin theyoj-json-jackson-v2module.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
forSchemaField
Detects the data binding type appropriate for the specified Schema field.- Parameters:
schemaField- schema field- Returns:
- database value type
- Throws:
IllegalArgumentException- if object of this type cannot be mapped to a database value- See Also:
-
forJavaType
public static FieldValueType forJavaType(@NonNull @NonNull Type type, @NonNull @NonNull ReflectField reflectField) Detects the data binding type appropriate for the specified Java value type that will be used with the specified Schema field. This method is more general thanforSchemaField(JavaField): it allows comparing not strictly equal values in filter expressions, e.g., the String value of the ID with the (flat) ID itself, which is a wrapper around String.- Parameters:
type- Java object type. E.g.,String.classfor a String literal from the userreflectField- reflection information for the Schema field that the object of typetypeis supposed to be used with. E.g., reflection information for the (flat) ID field which the String literal is compared with.- Returns:
- database value type
- Throws:
IllegalArgumentException- if object of this type cannot be mapped to a database value
-
forJavaType
public static FieldValueType forJavaType(@NonNull @NonNull Type type, @Nullable Column columnAnnotation, @Nullable CustomValueTypeInfo<?, ?> cvt) Detects the data binding type appropriate for the specified Java value type, provided that we know the@Columnannotation value as well as custom value type information.This method will most likely become package-private in YOJ 3.0.0! Please do not use it outside of YOJ code.
- Parameters:
type- Java object typecolumnAnnotation-@Columnannotation for the field;nullif absentcvt- custom value type information;nullif absent- Returns:
- database value type
- Throws:
IllegalArgumentException- if object of this type cannot be mapped to a database value
-
isComposite
public boolean isComposite()- Returns:
trueif this database value type is a composite;falseotherwise
-
byte[]will be removed in YOJ 3.0.0.