Enum Class FieldValueType

java.lang.Object
java.lang.Enum<FieldValueType>
tech.ydb.yoj.databind.FieldValueType
All Implemented Interfaces:
Serializable, Comparable<FieldValueType>, Constable

public enum FieldValueType extends Enum<FieldValueType>
Field value type for data binding.
  • Enum Constant Details

    • INTEGER

      public static final FieldValueType INTEGER
      Integer value. Java-side must either be a numeric primitive, or extend java.lang.Number and implement java.lang.Comparable.
    • REAL

      public static final FieldValueType REAL
      Real (floating-point) number value. Java-side must either be a numeric primitive, or extend java.lang.Number and implement java.lang.Comparable.
    • STRING

      public static final FieldValueType STRING
      String value. Java-side must be serialized to simple string value.
    • BOOLEAN

      public static final FieldValueType BOOLEAN
      Boolean value. Java-side must either be an instance of java.lang.Boolean or a boolean primitive.
    • ENUM

      public static final FieldValueType ENUM
      Enum value. Java-side must be an instance of java.lang.Enum.
      Typically stored as enum constant name or its ordinal.
    • TIMESTAMP

      public static final FieldValueType TIMESTAMP
      Timestamp. Java-side must be an instance of java.time.Instant.
    • INTERVAL

      public static final FieldValueType INTERVAL
      Interval. Java-side must be an instance of java.time.Duration.
    • BINARY

      @Deprecated public static final FieldValueType BINARY
      Deprecated.
      It is strongly recommended to use a ByteArray that is properly Comparable and has a sane equals().
      Binary value: just a stream of uninterpreted bytes. Java-side must be a byte array.

    • BYTE_ARRAY

      public static final FieldValueType BYTE_ARRAY
      Binary value: just a stream of uninterpreted bytes. Java-side must be a tech.ydb.yoj.databind.ByteArray.
    • COMPOSITE

      public static final FieldValueType 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

      public static final FieldValueType 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

      public static final FieldValueType 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

      public static FieldValueType[] 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

      public static FieldValueType valueOf(String name)
      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 name
      NullPointerException - 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 the CustomValueType annotation with a StringValueConverter instead of calling this method.

      To register a class not in your code (e.g., UUID from 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

      @NonNull public static @NonNull FieldValueType forJavaType(Type type, Column columnAnnotation)
      Detects database field type appropriate for a Java object of type type.
      Parameters:
      type - Java object type
      columnAnnotation - @Column annotation for the field; null if absent
      Returns:
      database value type
      Throws:
      IllegalArgumentException - if object of this type cannot be mapped to a database value
    • isComposite

      @Deprecated(forRemoval=true) public static boolean isComposite(@NonNull @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 @Column annotation on the field. Please do not call it directly, instead use FieldValueType.forJavaType(type, column).isComposite() where column is the @Column annotation's value.
      Checks whether Java object of type type is mapped to a composite database value (i.e. > 1 database field)
      Parameters:
      type - Java object type
      Returns:
      true if type maps to a composite database value; false otherwise
      Throws:
      IllegalArgumentException - if object of this type cannot be mapped to a database value
      See Also:
    • isComposite

      public boolean isComposite()
      Returns:
      true if this database value type is a composite; false otherwise
    • isUnknown

      public boolean isUnknown()
      Returns:
      true if there is no fitting database value type for the type provided; false otherwise
    • isSortable

      public boolean isSortable()