Class OpFunctions

java.lang.Object
org.apache.juneau.commons.svl.functions.OpFunctions

public final class OpFunctions extends Object
Reserved $op.* operator functions targeted by the compiled expression grammar.

Each operator is one VarFunction registered only under its reserved $op. name (never under a plain name). All are deniable via an allowlist like any other function. Arguments arrive already evaluated; short-circuiting (and, or, elvis, ternary) is the evaluator's job.

Coercion rules (SpEL-style):

  • Numeric tower: Byte/Short/Integer/Long stay long (overflow detected with Math.*Exact and promoted to BigDecimal); any Double/Float operand gives double (this wins over BigDecimal); otherwise any BigDecimal/BigInteger gives BigDecimal.
  • add concatenates when either operand is a String; a null operand renders as "null". sub/mul/div/mod/neg/pos are numeric only.
  • div of two integral values stays integral only when exact, otherwise double. Integral (and BigDecimal) division or modulo by zero is an error; by 0.0 follows IEEE 754.
  • eq/ne compare numbers numerically (1 == 1.0), otherwise Objects.equals(java.lang.Object, java.lang.Object).
  • lt/le/gt/ge compare numbers numerically or same-class Comparables; anything else is an error. A null operand is an error in strict mode and false in lenient mode.
  • and/or/not/ternary accept Boolean or the strings "true"/"false", matched case-insensitively (consistent with BooleanFunctions, whose parser also uses case-insensitive matching but additionally accepts 1/yes/on and 0/no/off, which operators deliberately do not). and and or validate both operands before combining.
  • Long.MIN_VALUE / -1 overflows and is promoted to BigDecimal; Long.MIN_VALUE % -1 is 0.
  • NaN is unordered: eq is false, ne true, and all relational operators false. 0.0 == -0.0. Long-versus-double comparison is exact (no precision loss).
  • add string concatenation renders doubles via ArithmeticFunctions.render(double) (integral values drop .0) and BigDecimal via toPlainString().
  • elvis is null-only: false, 0 and "" are kept.
  • matches uses a bounded shared pattern cache. There is no match timeout: ReDoS exposure is bounded only by the configured limits and the function allowlist.
  • Field Details

    • ALL

      public static final Class<? extends VarFunction>[] ALL
      All function classes in this category.