Class VariantValue

java.lang.Object
dev.frostlake.values.VariantValue
All Implemented Interfaces:
Serializable, Comparable<VariantValue>

public final class VariantValue extends Object implements Comparable<VariantValue>, Serializable
Runtime value of the SQL semi-structured family (VARIANT / OBJECT / ARRAY): canonical JSON text plus a lazily parsed tree.

Equality, ordering and hashing are all over the canonical text — the engine has always compared semi-structured values by their canonical JSON text (GROUP BY, DISTINCT, joins, set operators), and this class preserves exactly those semantics while letting strictly-typed callers (TYPEOF, GET, TO_JSON) know the value really is semi-structured rather than a VARCHAR that happens to look like JSON. Producers canonicalize (sorted object keys, descaled whole decimals) before wrapping; the text is stored verbatim here.

See Also:
  • Method Details

    • of

      public static VariantValue of(String canonicalText)
      Wraps canonical JSON text; the caller guarantees it is valid, canonical JSON.
    • ofNode

      public static VariantValue ofNode(tools.jackson.databind.JsonNode node)
      Wraps a parsed tree, rendering its (compact) JSON text once.
    • text

      public String text()
      The canonical JSON text.
    • node

      public tools.jackson.databind.JsonNode node()
      The parsed tree (parsed on first access; re-parsed after deserialization).
    • isJsonObject

      public boolean isJsonObject()
    • isJsonArray

      public boolean isJsonArray()
    • isJsonNull

      public boolean isJsonNull()
      A VARIANT JSON null (the text null) — distinct from SQL NULL.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • comparisonKey

      public String comparisonKey()
      The key two variants share exactly when they compare equal — numbers by value whatever their notation, objects whatever their key order — see VariantOrder.comparisonKey(tools.jackson.databind.JsonNode).
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(VariantValue other)
      The account's VARIANT order — by kind, then within the kind; see VariantOrder.
      Specified by:
      compareTo in interface Comparable<VariantValue>