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 be a long, int, short or byte, or an instance of their wrapper classes Long, Integer, Short or Byte.
    • REAL

      public static final FieldValueType REAL
      Real (floating-point) number value. Java-side must be a double or a float, or an instance of their wrapper classes Double or Float.
    • STRING

      public static final FieldValueType STRING
      String value. Java-side must be a String.
    • BOOLEAN

      public static final FieldValueType BOOLEAN
      Boolean value. Java-side must either be a boolean primitive, or an instance of its wrapper class Boolean.
    • ENUM

      public static final FieldValueType ENUM
      Enum value. Java-side must be a concrete subclass of java.lang.Enum.
    • 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.
    • UUID

      public static final FieldValueType UUID
      Universally Unique Identitifer (UUID). Java-side must be an instance of UUID.
    • BINARY

      @Deprecated(forRemoval=true) public static final FieldValueType BINARY
      Deprecated, for removal: This API element is subject to removal in a future version.
      Support for mapping raw byte[] will be removed in YOJ 3.0.0. Even now, it is strongly recommended to use a ByteArray: it is properly Comparable and has a sane equals(), 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 a byte[].

    • 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 value reflectable by YOJ: a Java Record, a Kotlin data class, an immutable POJO with all-args constructor annotated with @ConstructorProperties etc.
    • 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, ...).

      To marshal OBJECT values using YOJ, you must configure a JsonConverter by calling CommonConverter.defineJsonConverter() (in yoj-repository module). YOJ offers a reasonably configured Jackson-based JacksonJsonConverter in the yoj-json-jackson-v2 module.

  • 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
    • forSchemaField

      public static FieldValueType forSchemaField(@NonNull @NonNull Schema.JavaField schemaField)
      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 than forSchemaField(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.class for a String literal from the user
      reflectField - reflection information for the Schema field that the object of type type is 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 @Column annotation 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 type
      columnAnnotation - @Column annotation for the field; null if absent
      cvt - custom value type information; null if absent
      Returns:
      database value type
      Throws:
      IllegalArgumentException - if object of this type cannot be mapped to a database value
    • isComposite

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