Package ai.velr

Class VelrValue

java.lang.Object
ai.velr.VelrValue

public final class VelrValue extends Object
One typed Velr property value.

VelrValue preserves both the public Velr value kind and the underlying storage kind used for exact reconstruction. Vector embedding callbacks receive values through VectorEmbeddingField.velrValue() so embedders can choose between Java scalar accessors, canonical JSON, display text, and raw storage bytes.

  • Method Details

    • nullValue

      public static VelrValue nullValue()
      Create the Velr null value.
      Returns:
      a null Velr value
    • bool

      public static VelrValue bool(boolean value)
      Create a Velr boolean value.
      Parameters:
      value - boolean value
      Returns:
      a Velr boolean value
    • int64

      public static VelrValue int64(long value)
      Create a Velr 64-bit integer value.
      Parameters:
      value - integer value
      Returns:
      a Velr integer value
    • doubleValue

      public static VelrValue doubleValue(double value)
      Create a Velr double value.
      Parameters:
      value - finite double value
      Returns:
      a Velr double value
    • string

      public static VelrValue string(String value)
      Create a Velr string value.
      Parameters:
      value - string value
      Returns:
      a Velr string value
    • bytes

      public static VelrValue bytes(byte[] value, String valueJson, String display)
      Create a Velr bytes value.

      valueJson is the canonical JSON rendering and display is the human-readable rendering used by display() and toString().

      Parameters:
      value - raw bytes
      valueJson - canonical JSON rendering
      display - display rendering
      Returns:
      a Velr bytes value
    • canonical

      public static VelrValue canonical(VelrValueType type, VelrStorageType storageType, String valueJson, String display, byte[] storageBytes)
      Create a non-scalar Velr value from canonical renderings.

      Use the dedicated scalar factories for null, boolean, integer, double, string, and bytes values. This factory is intended for temporal, spatial, list, and vector values when the canonical JSON/display/storage representation is already available.

      Parameters:
      type - Velr value kind
      storageType - underlying storage kind
      valueJson - canonical JSON rendering
      display - display rendering
      storageBytes - raw TEXT or BLOB storage payload when available
      Returns:
      a Velr value
    • type

      public VelrValueType type()
      Return the public Velr value kind.
      Returns:
      value kind
    • storageType

      public VelrStorageType storageType()
      Return the underlying storage kind used for exact reconstruction.
      Returns:
      storage kind
    • asObject

      public Object asObject()
      Return the Java-native value for simple kinds.

      Scalars return null, Boolean, Long, Double, String, or byte[]. Temporal, spatial, list, and vector values return their canonical JSON text.

      Returns:
      Java-native value or canonical JSON text
    • isNull

      public boolean isNull()
      Return whether this value is the Velr null value.
      Returns:
      true for VelrValueType.NULL
    • isTemporal

      public boolean isTemporal()
      Return whether this value is one of Velr's temporal types.
      Returns:
      true for date, time, datetime, and duration values
    • isSpatial

      public boolean isSpatial()
      Return whether this value is one of Velr's spatial types.
      Returns:
      true for point, geometry, and geography values
    • asBoolean

      public boolean asBoolean()
      Return this value as a boolean.
      Returns:
      boolean value
    • asLong

      public long asLong()
      Return this value as a 64-bit integer.
      Returns:
      integer value
    • asDouble

      public double asDouble()
      Return this value as a double.
      Returns:
      double value
    • asString

      public String asString()
      Return this value as a string.
      Returns:
      string value
    • asBytes

      public byte[] asBytes()
      Return this value as bytes.
      Returns:
      a defensive copy of the byte value
    • valueJson

      public String valueJson()
      Return the canonical JSON rendering of the Velr value.
      Returns:
      canonical JSON text
    • display

      public String display()
      Return the display rendering suitable for text embedders and logs.
      Returns:
      display text
    • storageBytes

      public byte[] storageBytes()
      Return the raw TEXT or BLOB storage payload when the native storage representation has one.
      Returns:
      storage bytes, or an empty array when no byte-backed payload is available
    • asDateText

      public String asDateText()
      Return this date value as canonical text.
      Returns:
      date text
    • asLocalTimeText

      public String asLocalTimeText()
      Return this local-time value as canonical text.
      Returns:
      local-time text
    • asZonedTimeText

      public String asZonedTimeText()
      Return this zoned-time value as canonical text.
      Returns:
      zoned-time text
    • asLocalDateTimeText

      public String asLocalDateTimeText()
      Return this local-datetime value as canonical text.
      Returns:
      local-datetime text
    • asZonedDateTimeText

      public String asZonedDateTimeText()
      Return this zoned-datetime value as canonical text.
      Returns:
      zoned-datetime text
    • asDurationText

      public String asDurationText()
      Return this duration value as canonical text.
      Returns:
      duration text
    • asPointGeoJson

      public String asPointGeoJson()
      Return this point value as canonical GeoJSON.
      Returns:
      point GeoJSON
    • asGeometryGeoJson

      public String asGeometryGeoJson()
      Return this geometry value as canonical GeoJSON.
      Returns:
      geometry GeoJSON
    • asGeographyGeoJson

      public String asGeographyGeoJson()
      Return this geography value as canonical GeoJSON.
      Returns:
      geography GeoJSON
    • asListJson

      public String asListJson()
      Return this list value as canonical JSON.
      Returns:
      list JSON
    • asVectorJson

      public String asVectorJson()
      Return this vector value as canonical JSON.
      Returns:
      vector JSON
    • toString

      public String toString()
      Return the display rendering of this value.
      Overrides:
      toString in class Object
      Returns:
      display rendering