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.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.Value type is unknown.
It might be supported by the data binding implementation, but relying on that fact is not recommended. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull FieldValueTypeforJavaType(Type type, Column columnAnnotation) Detects database field type appropriate for a Java object of typetype.booleanstatic booleanisComposite(@NonNull Type type) Deprecated, for removal: This API element is subject to removal in a future version.This method does not properly take into account the customizations specified in the@Columnannotation on the field.booleanbooleanstatic voidregisterStringValueType(@NonNull Class<?> clazz) Deprecated, for removal: This API element is subject to removal in a future version.It is recommended to use theCustomValueTypeannotation with aStringValueConverterinstead of calling this method.static 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 either be a numeric primitive, or extendjava.lang.Numberand implementjava.lang.Comparable. -
REAL
Real (floating-point) number value. Java-side must either be a numeric primitive, or extendjava.lang.Numberand implementjava.lang.Comparable. -
STRING
String value. Java-side must be serialized to simple string value. -
BOOLEAN
Boolean value. Java-side must either be an instance ofjava.lang.Booleanor abooleanprimitive. -
ENUM
Enum value. Java-side must be an instance ofjava.lang.Enum.
Typically stored asenum constant nameor itsordinal. -
TIMESTAMP
Timestamp. Java-side must be an instance ofjava.time.Instant. -
INTERVAL
Interval. Java-side must be an instance ofjava.time.Duration. -
BINARY
Deprecated.Binary value: just a stream of uninterpreted bytes. Java-side must be a byte array. -
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 POJO with all-args constructor, e.g. a Lombok@Value-annotated class. -
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, ...). -
UNKNOWN
Value type is unknown.
It might be supported by the data binding implementation, but relying on that fact is not recommended.
-
-
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
-
registerStringValueType
@Deprecated(forRemoval=true) public static void registerStringValueType(@NonNull @NonNull Class<?> clazz) Deprecated, for removal: This API element is subject to removal in a future version.It is recommended to use theCustomValueTypeannotation with aStringValueConverterinstead of calling this method.To register a class not in your code (e.g.,
UUIDfrom the JDK) as a string-value type, use a@Column(customValueType=@CustomValueType(...))annotation on the specific field.Future versions of YOJ might remove this method entirely.
- Parameters:
clazz- class to register as string-value. Must either be final or sealed with permissible final-only implementations. All permissible implementations of a sealed class will be registered automatically.
-
forJavaType
Detects database field type appropriate for a Java object of typetype.- Parameters:
type- Java object typecolumnAnnotation-@Columnannotation for the field;nullif absent- Returns:
- database value type
- Throws:
IllegalArgumentException- if object of this type cannot be mapped to a database value
-
isComposite
Deprecated, for removal: This API element is subject to removal in a future version.Checks whether Java object of typetypeis mapped to a composite database value (i.e. > 1 database field)- Parameters:
type- Java object type- Returns:
trueiftypemaps to a composite database value;falseotherwise- Throws:
IllegalArgumentException- if object of this type cannot be mapped to a database value- See Also:
-
isComposite
public boolean isComposite()- Returns:
trueif this database value type is a composite;falseotherwise
-
isUnknown
public boolean isUnknown()- Returns:
trueif there is no fitting database value type for the type provided;falseotherwise
-
isSortable
public boolean isSortable()
-
ByteArraythat is properlyComparableand has a saneequals().