Class JexlArithmetic
This is the class to derive to implement new operator behaviors.
The 5 base arithmetic operators (+, - , *, /, %) follow the same evaluation rules regarding their arguments.
- If both are null, result is 0 if arithmetic (or operator) is non-strict, ArithmeticException is thrown otherwise
- If both arguments are numberable - any kind of integer including boolean -, coerce both to Long and coerce
   result to the most precise argument class (boolean < byte < short < int < long); if long operation would cause overflow, return a BigInteger
- If either argument is a BigDecimal, coerce both to BigDecimal, operator returns BigDecimal
- If either argument is a floating point number, coerce both to Double, operator returns Double
- Else treat as BigInteger, perform operation and narrow result to the most precise argument class
- Since:
- 2.0
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceHelper interface used when creating an array literal.static classMarker class for coercion operand exceptions.static interfaceHelper interface used when creating a map literal.static classMarker class for null operand exceptions.static interfaceHelper interface used when creating a set literal.static interfaceThe interface that uberspects JexlArithmetic classes.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected static final BigDecimalDouble.MAX_VALUE as BigDecimal.protected static final BigDecimal-Double.MAX_VALUE as BigDecimal.protected static final intDefault BigDecimal scale.protected static final BigIntegerLong.MAX_VALUE as BigInteger.protected static final BigIntegerLong.MIN_VALUE as BigInteger.static final PatternThe float regular expression pattern.
- 
Constructor SummaryConstructorsConstructorDescriptionJexlArithmetic(boolean astrict) Creates a JexlArithmetic.JexlArithmetic(boolean astrict, MathContext bigdContext, int bigdScale) Creates a JexlArithmetic.
- 
Method SummaryModifier and TypeMethodDescriptionAdd two values together.Performs a bitwise and.arrayBuilder(int size) Deprecated.since 3.3.1arrayBuilder(int size, boolean extended) Called by the interpreter when evaluating a literal array.protected NumberasLongNumber(boolean strict, Object value) Checks if value class is a number that can be represented exactly in a long.protected NumberasLongNumber(Object value) Checks if value class is a number that can be represented exactly in a long.final ObjectbitwiseAnd(Object lhs, Object rhs) Deprecated.3.0final ObjectDeprecated.3.0final ObjectbitwiseXor(Object lhs, Object rhs) Deprecated.3.0protected BooleancollectionContains(Object collection, Object value) Checks whether a potential collection contains another.protected intDeprecated.3.3protected intcompare(Object left, Object right, JexlOperator operator) Performs a comparison.complement(Object val) Performs a bitwise complement.Test if left contains right (right matches/in left).protected ObjectDeprecated.3.3protected ObjectcontrolNullNullOperands(JexlOperator operator) The result of +,/,-,*,% when both operands are null.protected voidDeprecated.3.3protected <T> TcontrolNullOperand(boolean strictCast, T defaultValue) Throws an NullOperand exception if arithmetic is strict-cast.controlReturn(Object returned) The last method called before returning a result from a script execution.Iterable<?> createRange(Object from, Object to) Creates a literal range.protected JexlArithmeticcreateWithOptions(boolean astrict, MathContext bigdContext, int bigdScale) Creates a JexlArithmetic instance.Decrements argument by 1.Divide the left value by the right.Check for emptiness of various types: Number, Collection, Array, Map, String.Test if left ends with right.booleanTest if left and right are equal.The MathContext instance used for +,-,/,*,% operations on big decimals.intThe BigDecimal scale used for comparison and coercion operations.booleangreaterThan(Object left, Object right) Test if left > right.booleangreaterThanOrEqual(Object left, Object right) Test if left >= right.Increments argument by 1.protected ObjectAdd value to number argument.Check for emptiness of various types: Number, Collection, Array, Map, String.Check for emptiness of various types: Number, Collection, Array, Map, String.protected booleanIs Object a floating point number.protected booleanTest if the passed value is a floating point number, i.e. a float, double or string with ( "." | "E" | "e").protected static booleanisMultiplyExact(long x, long y, long r) Checks if the product of the arguments overflows along.booleanTests whether negate called with a given argument will always return the same result.protected booleanisNullOperand(Object value) Checks if an operand is considered null.protected booleanIs Object a whole number.booleanTests whether positivize called with a given argument will always return the same result.booleanisStrict()Checks whether this JexlArithmetic instance strictly considers null as an error when used as operand unexpectedly.booleanisStrict(JexlOperator operator) Tests whether this arithmetic considers a given operator as strict or null-safe.booleanTests if left < right.booleanlessThanOrEqual(Object left, Object right) Tests if left <= right.final ObjectlogicalNot(Object arg) Deprecated.3.0mapBuilder(int size) Deprecated.3.3mapBuilder(int size, boolean extended) Called by the interpreter when evaluating a literal map.final ObjectDeprecated.3.0left value modulo right.Multiply the left value by the right.Given a Number, return the value using the smallest type the result will fit into.protected booleannarrowAccept(Class<?> narrow, Class<?> source) Tests whether we consider the narrow class as a potential candidate for narrowing the source.booleannarrowArguments(Object[] args) Replace all numbers in an arguments array with the smallest type that will fit.protected NumbernarrowBigDecimal(Object lhs, Object rhs, BigDecimal big) Given a BigDecimal, attempt to narrow it to an Integer or Long if it fits and one of the arguments is numberable.protected NumbernarrowBigInteger(Object lhs, Object rhs, BigInteger big) Given a BigInteger, narrow it to an Integer or Long if it fits and the arguments class allow it.protected NumbernarrowLong(Object lhs, Object rhs, long r) Given a long, attempt to narrow it to an int.narrowNumber(Number original, Class<?> narrow) Given a Number, return the value attempting to narrow it to a target class.Negates a value (unary minus for numbers).Performs a logical not.options(JexlContext context) Apply options to this arithmetic which eventually may create another instance.options(JexlEngine.Options options) Deprecated.3.2options(JexlOptions options) Apply options to this arithmetic which eventually may create another instance.Performs a bitwise or.static IntegerParse an identifier which must be of the form: 0|([1-9][0-9]*)positivize(Object val) Positivize value (unary plus for numbers).protected BigDecimalroundBigDecimal(BigDecimal number) Ensure a big decimal is rounded by this arithmetic scale and rounding mode.setBuilder(int size) Deprecated.since 3.3.1setBuilder(int size, boolean extended) Called by the interpreter when evaluating a literal set.Shifts a bit pattern to the right.shiftRight(Object left, Object right) Shifts a bit pattern to the right.shiftRightUnsigned(Object left, Object right) Shifts a bit pattern to the right unsigned.Calculate thesizeof various types: Collection, Array, Map, String.Calculate thesizeof various types: Collection, Array, Map, String.startsWith(Object left, Object right) Test if left starts with right.booleanstrictEquals(Object left, Object right) Test if left and right are strictly equal.Subtract the right value from the left.booleantestPredicate(Object object) Test if a condition is true or false.protected BigDecimaltoBigDecimal(boolean strict, Object val) Coerce to a BigDecimal.toBigDecimal(Object val) Coerce to a BigDecimal.protected BigIntegertoBigInteger(boolean strict, Object val) Coerce to a BigInteger.toBigInteger(Object val) Coerce to a BigInteger.protected booleanCoerce to a primitive boolean.booleanCoerce to a primitive boolean.protected doubleCoerce to a primitive double.doubleCoerce to a primitive double.protected intCoerce to a primitive int.intCoerce to a primitive int.protected longCoerce to a primitive long.longCoerce to a primitive long.protected StringCoerce to a string.Coerce to a string.Performs a bitwise xor.
- 
Field Details- 
BIGD_DOUBLE_MAX_VALUEDouble.MAX_VALUE as BigDecimal.
- 
BIGD_DOUBLE_MIN_VALUE-Double.MAX_VALUE as BigDecimal.
- 
BIGI_LONG_MAX_VALUELong.MAX_VALUE as BigInteger.
- 
BIGI_LONG_MIN_VALUELong.MIN_VALUE as BigInteger.
- 
BIGD_SCALEDefault BigDecimal scale.- See Also:
 
- 
FLOAT_PATTERNThe float regular expression pattern.The decimal and exponent parts are optional and captured allowing to determine if the number is a real by checking whether one of these 2 capturing groups is not empty. 
 
- 
- 
Constructor Details- 
JexlArithmeticCreates a JexlArithmetic.If you derive your own arithmetic, implement the other constructor that may be needed when dealing with options. - Parameters:
- astrict- whether this arithmetic is strict or lenient
 
- 
JexlArithmeticCreates a JexlArithmetic.The constructor to define in derived classes. - Parameters:
- astrict- whether this arithmetic is lenient or strict
- bigdContext- the math context instance to use for +,-,/,*,% operations on big decimals.
- bigdScale- the scale used for big decimals.
 
 
- 
- 
Method Details- 
isMultiplyExactChecks if the product of the arguments overflows along.see java8 Math.multiplyExact - Parameters:
- x- the first value
- y- the second value
- r- the product
- Returns:
- true if product fits a long, false if it overflows
 
- 
addAdd two values together.If any numeric add fails on coercion to the appropriate type, treat as Strings and do concatenation. - Parameters:
- left- left argument
- right- right argument
- Returns:
- left + right.
 
- 
andPerforms a bitwise and.- Parameters:
- left- the left operand
- right- the right operator
- Returns:
- left & right
 
- 
arrayBuilderDeprecated.since 3.3.1Creates an array builder.- Parameters:
- size- the number of elements in the array
- Returns:
- an array builder instance
 
- 
arrayBuilderCalled by the interpreter when evaluating a literal array.- Parameters:
- size- the number of elements in the array
- extended- whether the map is extended or not
- Returns:
- the array builder
 
- 
asLongNumberChecks if value class is a number that can be represented exactly in a long.For convenience, booleans are converted as 1/0 (true/false). - Parameters:
- strict- whether null argument is converted as 0 or remains null
- value- argument
- Returns:
- a non-null value if argument can be represented by a long
 
- 
asLongNumberChecks if value class is a number that can be represented exactly in a long.For convenience, booleans are converted as 1/0 (true/false). - Parameters:
- value- argument
- Returns:
- a non-null value if argument can be represented by a long
 
- 
bitwiseAndDeprecated.3.0Use or overload and() instead.- Parameters:
- lhs- left hand side
- rhs- right hand side
- Returns:
- lhs & rhs
- See Also:
 
- 
bitwiseOrDeprecated.3.0Use or overload or() instead.- Parameters:
- lhs- left hand side
- rhs- right hand side
- Returns:
- lhs | rhs
- See Also:
 
- 
bitwiseXorDeprecated.3.0Use or overload xor() instead.- Parameters:
- lhs- left hand side
- rhs- right hand side
- Returns:
- lhs ^ rhs
- See Also:
 
- 
collectionContainsChecks whether a potential collection contains another.Made protected to make it easier to override if needed. - Parameters:
- collection- the container which can be a collection or an array (even of primitive)
- value- the value which can be a collection or an array (even of primitive) or a singleton
- Returns:
- test result or null if there is no arithmetic solution
 
- 
comparePerforms a comparison.- Parameters:
- left- the left operand
- right- the right operator
- operator- the operator
- Returns:
- -1 if left < right; +1 if left > right; 0 if left == right
- Throws:
- ArithmeticException- if either left or right is null
 
- 
compareDeprecated.3.3Any override of this method (pre 3.3) should be modified to match the new signature.- Parameters:
- left- left operand
- right- right operand
- symbol- the operator symbol
- Returns:
- -1 if left < right; +1 if left > right; 0 if left == right
 compare(Object, Object, JexlOperator)
 
- 
complementPerforms a bitwise complement.- Parameters:
- val- the operand
- Returns:
- ~val
 
- 
containsTest if left contains right (right matches/in left).Beware that this "contains " method arguments order is the opposite of the "in/matches" operator arguments. x =~ ymeansy contains xthuscontains(x, y).When this method returns null during evaluation, the operator code continues trying to find one through the uberspect. - Parameters:
- container- the container
- value- the value
- Returns:
- test result or null if there is no arithmetic solution
 
- 
controlNullNullOperandsDeprecated.3.3The result of +,/,-,*,% when both operands are null.- Returns:
- Integer(0) if lenient
- Throws:
- JexlArithmetic.NullOperand- if strict
 
- 
controlNullNullOperandsThe result of +,/,-,*,% when both operands are null.- Parameters:
- operator- the actual operator
- Returns:
- Integer(0) if lenient
- Throws:
- JexlArithmetic.NullOperand- if strict-cast
- Since:
- 3.3
 
- 
controlNullOperandDeprecated.3.3Throws an NullOperand exception if arithmetic is strict-cast.- Throws:
- JexlArithmetic.NullOperand- if strict
 
- 
controlNullOperandThrows an NullOperand exception if arithmetic is strict-cast.This method is called by the cast methods ( toBoolean(boolean, Object),toInteger(boolean, Object),toDouble(boolean, Object),toString(boolean, Object),toBigInteger(boolean, Object),toBigDecimal(boolean, Object)) when they encounter a null argument.- Type Parameters:
- T- the value type
- Parameters:
- strictCast- whether strict cast is required
- defaultValue- the default value to return, if not strict
- Returns:
- the default value is strict is false
- Throws:
- JexlArithmetic.NullOperand- if strict-cast
- Since:
- 3.3
 
- 
controlReturnThe last method called before returning a result from a script execution.- Parameters:
- returned- the returned value
- Returns:
- the controlled returned value
 
- 
createRangeCreates a literal range.The default implementation only accepts integers and longs. - Parameters:
- from- the included lower bound value (null if none)
- to- the included upper bound value (null if none)
- Returns:
- the range as an iterable
- Throws:
- ArithmeticException- as an option if creation fails
 
- 
createWithOptionsCreates a JexlArithmetic instance. Called by options(...) method when another instance of the same class of arithmetic is required.- Parameters:
- astrict- whether this arithmetic is lenient or strict
- bigdContext- the math context instance to use for +,-,/,*,% operations on big decimals.
- bigdScale- the scale used for big decimals.
- Returns:
- default is a new JexlArithmetic instance
- Since:
- 3.1
- See Also:
 
- 
decrementDecrements argument by 1.- Parameters:
- val- the argument
- Returns:
- val - 1
 
- 
divideDivide the left value by the right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left / right
- Throws:
- ArithmeticException- if right == 0
 
- 
emptyCheck for emptiness of various types: Number, Collection, Array, Map, String.Override or overload this method to add new signatures to the size operators. - Parameters:
- object- the object to check the emptiness of
- Returns:
- the boolean or false if object is not null
- Since:
- 3.2
 
- 
endsWithTest if left ends with right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left $= right if there is no arithmetic solution
 
- 
equalsTest if left and right are equal.- Parameters:
- left- left argument
- right- right argument
- Returns:
- the test result
 
- 
getMathContextThe MathContext instance used for +,-,/,*,% operations on big decimals.- Returns:
- the math context
 
- 
getMathScaleThe BigDecimal scale used for comparison and coercion operations.- Returns:
- the scale
 
- 
greaterThanTest if left > right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- the test result
 
- 
greaterThanOrEqualTest if left >= right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- the test result
 
- 
incrementIncrements argument by 1.- Parameters:
- val- the argument
- Returns:
- val + 1
 
- 
incrementAdd value to number argument.- Parameters:
- val- the number
- incr- the value to add
- Returns:
- val + incr
 
- 
isEmptyCheck for emptiness of various types: Number, Collection, Array, Map, String.- Parameters:
- object- the object to check the emptiness of
- Returns:
- the boolean or null if there is no arithmetic solution
 
- 
isEmptyCheck for emptiness of various types: Number, Collection, Array, Map, String.- Parameters:
- object- the object to check the emptiness of
- def- the default value if object emptiness cannot be determined
- Returns:
- the boolean or null if there is no arithmetic solution
 
- 
isFloatingPointIs Object a floating point number.- Parameters:
- o- Object to be analyzed.
- Returns:
- true if it is a Float or a Double.
 
- 
isFloatingPointNumberTest if the passed value is a floating point number, i.e. a float, double or string with ( "." | "E" | "e").- Parameters:
- val- the object to be tested
- Returns:
- true if it is, false otherwise.
 
- 
isNegateStableTests whether negate called with a given argument will always return the same result.This is used to determine whether negate results on number literals can be cached. If the result on calling negate with the same constant argument may change between calls, which means the function is not deterministic, this method must return false. - Returns:
- true if negate is idempotent, false otherwise
 
- 
isNullOperandChecks if an operand is considered null.- Parameters:
- value- the operand
- Returns:
- true if operand is considered null
 
- 
isNumberableIs Object a whole number.- Parameters:
- o- Object to be analyzed.
- Returns:
- true if Integer, Long, Byte, Short or Character.
 
- 
isPositivizeStableTests whether positivize called with a given argument will always return the same result.This is used to determine whether positivize results on number literals can be cached. If the result on calling positivize with the same constant argument may change between calls, which means the function is not deterministic, this method must return false. - Returns:
- true if positivize is idempotent, false otherwise
 
- 
isStrictChecks whether this JexlArithmetic instance strictly considers null as an error when used as operand unexpectedly.- Returns:
- true if strict, false if lenient
 
- 
isStrictTests whether this arithmetic considers a given operator as strict or null-safe.When an operator is strict, it does not accept null arguments when the arithmetic is strict. If null-safe (ie not-strict), the operator does accept null arguments even if the arithmetic itself is strict. The default implementation considers equal/not-equal operators as null-safe so one can check for null as in if (myvar == null) {...}. Note that this operator is used for equal and not-equal syntax. The complete list of operators that are not strict are (==, [], []=, ., .=, empty, size, contains).An arithmetic refining its strict behavior handling for more operators must declare which by overriding this method. - Parameters:
- operator- the operator to check for null-argument(s) handling
- Returns:
- true if operator considers null arguments as errors, false if operator has appropriate semantics for null argument(s)
 
- 
lessThanTests if left < right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- the test result
 
- 
lessThanOrEqualTests if left <= right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- the test result
 
- 
logicalNotDeprecated.3.0Use or overload not() instead.- Parameters:
- arg- argument
- Returns:
- !arg
- See Also:
 
- 
mapBuilderDeprecated.3.3Creates a map-builder.- Parameters:
- size- the number of elements in the map
- Returns:
- a map-builder instance
 
- 
mapBuilderCalled by the interpreter when evaluating a literal map.- Parameters:
- size- the number of elements in the map
- extended- whether the map is extended or not
- Returns:
- the map builder
 
- 
matchesDeprecated.3.0Use or overload contains() instead.- Parameters:
- lhs- left hand side
- rhs- right hand side
- Returns:
- contains(rhs, lhs)
- See Also:
 
- 
modleft value modulo right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left % right
- Throws:
- ArithmeticException- if right == 0.0
 
- 
multiplyMultiply the left value by the right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left * right.
 
- 
narrowGiven a Number, return the value using the smallest type the result will fit into.This works hand in hand with parameter 'widening' in Java method calls, e.g. a call to substring(int,int) with an int and a long will fail, but a call to substring(int,int) with an int and a short will succeed. - Parameters:
- original- the original number.
- Returns:
- a value of the smallest type the original number will fit into.
 
- 
narrowAcceptTests whether we consider the narrow class as a potential candidate for narrowing the source.- Parameters:
- narrow- the target narrow class
- source- the original source class
- Returns:
- true if attempt to narrow source to target is accepted
 
- 
narrowArgumentsReplace all numbers in an arguments array with the smallest type that will fit.- Parameters:
- args- the argument array
- Returns:
- true if some arguments were narrowed and args array is modified, false if no narrowing occurred and args array has not been modified
 
- 
narrowBigDecimalGiven a BigDecimal, attempt to narrow it to an Integer or Long if it fits and one of the arguments is numberable.- Parameters:
- lhs- the left-hand side operand that lead to the bigd result
- rhs- the right-hand side operand that lead to the bigd result
- big- the BigDecimal to narrow
- Returns:
- an Integer or Long if narrowing is possible, the original BigDecimal otherwise
 
- 
narrowBigIntegerGiven a BigInteger, narrow it to an Integer or Long if it fits and the arguments class allow it.The rules are: if either arguments is a BigInteger, no narrowing will occur if either arguments is a Long, no narrowing to Integer will occur - Parameters:
- lhs- the left-hand side operand that lead to the bigi result
- rhs- the right-hand side operand that lead to the bigi result
- big- the BigInteger to narrow
- Returns:
- an Integer or Long if narrowing is possible, the original BigInteger otherwise
 
- 
narrowLongGiven a long, attempt to narrow it to an int.Narrowing will only occur if no operand is a Long. - Parameters:
- lhs- the left hand side operand that lead to the long result
- rhs- the right hand side operand that lead to the long result
- r- the long to narrow
- Returns:
- an Integer if narrowing is possible, the original Long otherwise
 
- 
narrowNumberGiven a Number, return the value attempting to narrow it to a target class.- Parameters:
- original- the original number
- narrow- the attempted target class
- Returns:
- the narrowed number or the source if no narrowing was possible
 
- 
negateNegates a value (unary minus for numbers).- Parameters:
- val- the value to negate
- Returns:
- the negated value
- See Also:
 
- 
notPerforms a logical not.- Parameters:
- val- the operand
- Returns:
- !val
 
- 
optionsApply options to this arithmetic which eventually may create another instance.- Parameters:
- context- the context that may extend- JexlContext.OptionsHandleto use
- Returns:
- a new arithmetic instance or this
- Since:
- 3.1
- See Also:
 
- 
optionsDeprecated.3.2Apply options to this arithmetic which eventually may create another instance.- Parameters:
- options- the- JexlEngine.Optionsto use
- Returns:
- an arithmetic with those options set
- See Also:
 
- 
optionsApply options to this arithmetic which eventually may create another instance.- Parameters:
- options- the- JexlEngine.Optionsto use
- Returns:
- an arithmetic with those options set
- See Also:
 
- 
orPerforms a bitwise or.- Parameters:
- left- the left operand
- right- the right operator
- Returns:
- left | right
 
- 
parseIdentifierParse an identifier which must be of the form: 0|([1-9][0-9]*)- Parameters:
- id- the identifier
- Returns:
- an integer or null
 
- 
positivizePositivize value (unary plus for numbers).C/C++/C#/Java perform integral promotion of the operand, ie cast to int if type can be represented as int without loss of precision. - Parameters:
- val- the value to positivize
- Returns:
- the positive value
- See Also:
 
- 
roundBigDecimalEnsure a big decimal is rounded by this arithmetic scale and rounding mode.- Parameters:
- number- the big decimal to round
- Returns:
- the rounded big decimal
 
- 
setBuilderDeprecated.since 3.3.1Creates a set-builder.- Parameters:
- size- the number of elements in the set
- Returns:
- a set-builder instance
 
- 
setBuilderCalled by the interpreter when evaluating a literal set.- Parameters:
- size- the number of elements in the set
- extended- whether the set is extended or not
- Returns:
- the array builder
 
- 
shiftLeftShifts a bit pattern to the right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left << right.
 
- 
shiftRightShifts a bit pattern to the right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left >> right.
 
- 
shiftRightUnsignedShifts a bit pattern to the right unsigned.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left >>> right.
 
- 
sizeCalculate thesizeof various types: Collection, Array, Map, String.- Parameters:
- object- the object to get the size of
- Returns:
- the size of object, 0 if null, 1 if there is no better solution
 
- 
sizeCalculate thesizeof various types: Collection, Array, Map, String.- Parameters:
- object- the object to get the size of
- def- the default value if object size cannot be determined
- Returns:
- the size of object or null if there is no arithmetic solution
 
- 
startsWithTest if left starts with right.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left ^= right or null if there is no arithmetic solution
 
- 
strictEqualsTest if left and right are strictly equal.They must have the same class, comparable and the comparison returns 0. - Parameters:
- left- left argument
- right- right argument
- Returns:
- the test result
 
- 
subtractSubtract the right value from the left.- Parameters:
- left- left argument
- right- right argument
- Returns:
- left - right.
 
- 
testPredicateTest if a condition is true or false.- Parameters:
- object- the object to use as condition
- Returns:
- true or false
- Since:
- 3.3
 
- 
toBigDecimalCoerce to a BigDecimal.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- strict- true if the calling operator or casting is strict, false otherwise
- val- the object to be coerced.
- Returns:
- a BigDecimal.
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
- Since:
- 3.3
 
- 
toBigDecimalCoerce to a BigDecimal.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- val- the object to be coerced.
- Returns:
- a BigDecimal.
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
 
- 
toBigIntegerCoerce to a BigInteger.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- strict- true if the calling operator or casting is strict, false otherwise
- val- the object to be coerced.
- Returns:
- a BigDecimal
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
- Since:
- 3.3
 
- 
toBigIntegerCoerce to a BigInteger.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- val- the object to be coerced.
- Returns:
- a BigDecimal
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
 
- 
toBooleanCoerce to a primitive boolean.Double.NaN, null, "false" and empty string coerce to false. - Parameters:
- strict- true if the calling operator or casting is strict, false otherwise
- val- value to coerce
- Returns:
- the boolean value if coercion is possible, true if value was not null.
 
- 
toBooleanCoerce to a primitive boolean.Double.NaN, null, "false" and empty string coerce to false. - Parameters:
- val- value to coerce
- Returns:
- the boolean value if coercion is possible, true if value was not null.
 
- 
toDoubleCoerce to a primitive double.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- strict- true if the calling operator or casting is strict, false otherwise
- val- value to coerce.
- Returns:
- The double coerced value.
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
- Since:
- 3.3
 
- 
toDoubleCoerce to a primitive double.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- val- value to coerce.
- Returns:
- The double coerced value.
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
 
- 
toIntegerCoerce to a primitive int.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- strict- true if the calling operator or casting is strict, false otherwise
- val- value to coerce
- Returns:
- the value coerced to int
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
- Since:
- 3.3
 
- 
toIntegerCoerce to a primitive int.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- val- value to coerce
- Returns:
- the value coerced to int
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
 
- 
toLongCoerce to a primitive long.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- strict- true if the calling operator or casting is strict, false otherwise
- val- value to coerce
- Returns:
- the value coerced to long
- Throws:
- ArithmeticException- if value is null and mode is strict or if coercion is not possible
- Since:
- 3.3
 
- 
toLongCoerce to a primitive long.Double.NaN, null and empty string coerce to zero. Boolean false is 0, true is 1. - Parameters:
- val- value to coerce
- Returns:
- the value coerced to long
- Throws:
- ArithmeticException- if value is null and mode is strict or if coercion is not possible
 
- 
toStringCoerce to a string.Double.NaN coerce to the empty string. - Parameters:
- strict- true if the calling operator or casting is strict, false otherwise
- val- value to coerce.
- Returns:
- The String coerced value.
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
- Since:
- 3.3
 
- 
toStringCoerce to a string.Double.NaN coerce to the empty string. - Parameters:
- val- value to coerce.
- Returns:
- The String coerced value.
- Throws:
- ArithmeticException- if val is null and mode is strict or if coercion is not possible
 
- 
xorPerforms a bitwise xor.- Parameters:
- left- the left operand
- right- the right operator
- Returns:
- left ^ right
 
 
-