Class VariantNumbers

java.lang.Object
dev.frostlake.executor.expressions.VariantNumbers

public final class VariantNumbers extends Object
A VARIANT read as a number wherever a number is needed: its JSON number, its JSON string when that spells one, and a JSON boolean as 1 / 0. Anything else — an object, an array, a string that spells no number — fails the variant CAST, naming the member as JSON and the numeric family the use asked for: Failed to cast variant value {"x":1} to REAL for an operator or a numeric function and the double-valued aggregates, … to FIXED for the integer ones (live-verified across + - * / %, the unary sign, ABS / ROUND / FLOOR / SQRT / MOD and their family, SUM / AVG / MEDIAN / BITOR_AGG).
  • Field Details

  • Method Details

    • numberOf

      public static Number numberOf(VariantValue variant, String target)
      The number a VARIANT member converts to, or null for a JSON null.
      Parameters:
      variant - the value
      target - REAL or FIXED, named by the refusal
      Returns:
      its number
    • refusal

      public static NumericConversionException refusal(tools.jackson.databind.JsonNode node, String target)
      The refusal for a member that reads as no number.
      Parameters:
      node - the member
      target - REAL or FIXED
      Returns:
      the exception to throw