Class ExactValues

java.lang.Object
dev.frostlake.values.ExactValues

public final class ExactValues extends Object
The ONE carrier an exact NUMBER(p, s) column holds, whatever path a value arrives by. A scale-0 column holds a Long for every whole value that fits one and a scale-0 BigDecimal beyond the long range; a scaled column holds a BigDecimal at exactly its scale, rounded HALF_UP from whatever was written. Before this, the same column held a Long from an INSERT of a literal beside a BigDecimal from an UPDATE or a VARIANT cast, and every raw equals or Comparable seam — a DISTINCT set, a join key, a MIN / MAX fast path — could meet one number in two classes. The FLOAT family has the same rule in ApproximateValues.
  • Method Details

    • written

      public static Object written(Object value, NumericType type)
      The value as its column stores it.
      Parameters:
      value - the value written, or null
      type - the column's numeric type
      Returns:
      the carrier — a Long or a BigDecimal — or the value itself when it is not a number the column can hold (a NULL, a non-numeric, a NaN) or the column is approximate
    • isCarrier

      public static boolean isCarrier(Object value, NumericType type)
      Whether a cell already is the carrier its column holds — the check every write makes before touching a row.
      Parameters:
      value - the cell, not null
      type - the column's exact numeric type
      Returns:
      true when the cell can be stored as it is