Class ExpressionArithmetic

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

public final class ExpressionArithmetic extends Object
Pure arithmetic, temporal and comparison helpers extracted from ExpressionEvaluatorVisitor: numeric/date add/subtract/multiply/divide/negate, three-valued truthiness, value equality/ordering and INTERVAL application. Field-free — all inputs arrive as arguments.
  • Method Summary

    Modifier and Type
    Method
    Description
    static BigDecimal
    The exact remainder with the operands' rescale check — the step % and MOD share: an operand that cannot be represented at the common scale is refused before any arithmetic, with the aligned type and its own digits (live-verified for the function as for the operator).
    static boolean
    equals(Object left, Object right)
    SQL value equality, as the = operator answers it: numbers compare by VALUE whatever their runtime class, a boolean reads against a number, a temporal against its own text, a DATE against a TIMESTAMP by instant, and a VARIANT against either.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • equals

      public static boolean equals(Object left, Object right)
      SQL value equality, as the = operator answers it: numbers compare by VALUE whatever their runtime class, a boolean reads against a number, a temporal against its own text, a DATE against a TIMESTAMP by instant, and a VARIANT against either. A string that must read as a number and cannot is an error, not an inequality: 'ab' = 1 raises "Numeric value 'ab' is not recognized".

      Exposed so the functions that are defined AS a comparison — DECODE today — answer with the operator instead of a hand-rolled test of their own. It is the only member of this class visible outside the package; the rest stay package-private.

    • checkedRemainder

      public static BigDecimal checkedRemainder(BigDecimal dividend, BigDecimal divisor)
      The exact remainder with the operands' rescale check — the step % and MOD share: an operand that cannot be represented at the common scale is refused before any arithmetic, with the aligned type and its own digits (live-verified for the function as for the operator).
      Parameters:
      dividend - the dividend
      divisor - the divisor
      Returns:
      the dividend-signed remainder