Class VariantNumbers
java.lang.Object
dev.frostlake.executor.expressions.VariantNumbers
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic NumbernumberOf(VariantValue variant, String target) The number a VARIANT member converts to, or null for a JSON null.static NumericConversionExceptionThe refusal for a member that reads as no number.
-
Field Details
-
REAL
The target of a double-valued use.- See Also:
-
FIXED
The target of an integer-valued use.- See Also:
-
-
Method Details
-
numberOf
The number a VARIANT member converts to, or null for a JSON null.- Parameters:
variant- the valuetarget- 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 membertarget- REAL or FIXED- Returns:
- the exception to throw
-