Package org.apache.commons.jexl3
Enum JexlOperator
- All Implemented Interfaces:
Serializable
,Comparable<JexlOperator>
The JEXL operators.
These are the operators that are executed by JexlArithmetic methods.
Each of them associates a symbol to a method signature. For instance, '+' is associated to 'T add(L x, R y)'.
The default JexlArithmetic implements generic versions of these methods using Object as arguments. You can use your own derived JexlArithmetic that override and/or overload those operator methods. Note that these are overloads by convention, not actual Java overloads. The following rules apply to all operator methods:
- Operator methods should be public
- Operators return type should be respected when primitive (int, boolean,...)
- Operators may be overloaded multiple times with different signatures
- Operators may return JexlEngine.TRY_AGAIN to fallback on default JEXL implementation
- JexlEngine.TRY_FAIL to let the default fallback behavior be executed.
- Any other value will be used as the new value to be assigned to the left-hand-side.
- Since:
- 3.0
-
Enum Constant Summary
Enum ConstantDescriptionAdd operator.Bitwise-and operator.Array get operator as in: x[y].Array set operator as in: x[y] = z.Marker for side effect.Complement operator.Test condition in if, for, while.Contains operator.Decrement pseudo-operator.Prefix --, decrements and returns the value after decrementing.Divide operator.Empty operator.Ends-with operator.Equals operator.Equal-strict operator.Iterator generator as in for(var x : y).Postfix --, decrements and returns the value before decrementing.Postfix ++, increments and returns the value before incrementing.Greater-than operator.Greater-than-or-equal operator.Increment pseudo-operator.Prefix ++ operator, increments and returns the value after incrementing.Less-than operator.Less-than-or-equal operator.Modulo operator.Multiply operator.Negate operator.Not operator.Bitwise-or operator.Positivize operator.Property get operator as in: x.y.Property set operator as in: x.y = z.Self-add operator.Self-and operator.Self-divide operator.Self-modulo operator.Self-multiply operator.Self-or operator.Self-left-shift operator.Self-right-shift operator.Self-right-shift unsigned operator.Self-subtract operator.Self-xor operator.Bit-pattern left-shift operator.Bit-pattern right-shift operator.Bit-pattern right-shift unsigned operator.Size operator.Starts-with operator.Subtract operator.Bitwise-xor operator. -
Method Summary
Modifier and TypeMethodDescriptionint
getArity()
Gets this operator number of parameters.final JexlOperator
Gets the base operator.final String
Gets this operator method name in a JexlArithmetic.final String
Gets this operator symbol.static JexlOperator
Returns the enum constant of this type with the specified name.static JexlOperator[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
ADD
Add operator.
Syntax:x + y
Method:T add(L x, R y);
.- See Also:
-
SUBTRACT
Subtract operator.
Syntax:x - y
Method:T subtract(L x, R y);
.- See Also:
-
MULTIPLY
Multiply operator.
Syntax:x * y
Method:T multiply(L x, R y);
.- See Also:
-
DIVIDE
Divide operator.
Syntax:x / y
Method:T divide(L x, R y);
.- See Also:
-
MOD
Modulo operator.
Syntax:x % y
Method:T mod(L x, R y);
.- See Also:
-
AND
Bitwise-and operator.
Syntax:x & y
Method:T and(L x, R y);
.- See Also:
-
OR
Bitwise-or operator.
Syntax:x | y
Method:T or(L x, R y);
.- See Also:
-
XOR
Bitwise-xor operator.
Syntax:x ^ y
Method:T xor(L x, R y);
.- See Also:
-
SHIFTRIGHT
Bit-pattern right-shift operator.
Syntax:x >> y
Method:T rightShift(L x, R y);
. -
SHIFTRIGHTU
Bit-pattern right-shift unsigned operator.
Syntax:x >>> y
Method:T rightShiftUnsigned(L x, R y);
. -
SHIFTLEFT
Bit-pattern left-shift operator.
Syntax:x << y
Method:T leftShift(L x, R y);
.- See Also:
-
EQ
Equals operator.
Syntax:x == y
Method:boolean equals(L x, R y);
.- See Also:
-
EQSTRICT
Equal-strict operator.
Syntax:x === y
Method:boolean strictEquals(L x, R y);
. -
LT
Less-than operator.
Syntax:x < y
Method:boolean lessThan(L x, R y);
.- See Also:
-
LTE
Less-than-or-equal operator.
Syntax:x <= y
Method:boolean lessThanOrEqual(L x, R y);
. -
GT
Greater-than operator.
Syntax:x > y
Method:boolean greaterThan(L x, R y);
. -
GTE
Greater-than-or-equal operator.
Syntax:x >= y
Method:boolean greaterThanOrEqual(L x, R y);
. -
CONTAINS
Contains operator.
Syntax:x =~ y
Method:boolean contains(L x, R y);
.- See Also:
-
STARTSWITH
Starts-with operator.
Syntax:x =^ y
Method:boolean startsWith(L x, R y);
. -
ENDSWITH
Ends-with operator.
Syntax:x =$ y
Method:boolean endsWith(L x, R y);
.- See Also:
-
NOT
Not operator.
Syntax:!x
Method:T not(L x);
.- See Also:
-
COMPLEMENT
Complement operator.
Syntax:~x
Method:T complement(L x);
.- See Also:
-
NEGATE
Negate operator.
Syntax:-x
Method:T negate(L x);
.- See Also:
-
POSITIVIZE
Positivize operator.
Syntax:+x
Method:T positivize(L x);
.- See Also:
-
EMPTY
Empty operator.
Syntax:empty x
orempty(x)
Method:boolean empty(L x);
.- See Also:
-
SIZE
Size operator.
Syntax:size x
orsize(x)
Method:int size(L x);
.- See Also:
-
SELF_ADD
Self-add operator.
Syntax:x += y
Method:T selfAdd(L x, R y);
. -
SELF_SUBTRACT
Self-subtract operator.
Syntax:x -= y
Method:T selfSubtract(L x, R y);
. -
SELF_MULTIPLY
Self-multiply operator.
Syntax:x *= y
Method:T selfMultiply(L x, R y);
. -
SELF_DIVIDE
Self-divide operator.
Syntax:x /= y
Method:T selfDivide(L x, R y);
. -
SELF_MOD
Self-modulo operator.
Syntax:x %= y
Method:T selfMod(L x, R y);
. -
SELF_AND
Self-and operator.
Syntax:x &= y
Method:T selfAnd(L x, R y);
. -
SELF_OR
Self-or operator.
Syntax:x |= y
Method:T selfOr(L x, R y);
. -
SELF_XOR
Self-xor operator.
Syntax:x ^= y
Method:T selfXor(L x, R y);
. -
SELF_SHIFTRIGHT
Self-right-shift operator.
Syntax:x >>= y
Method:T selfShiftRight(L x, R y);
. -
SELF_SHIFTRIGHTU
Self-right-shift unsigned operator.
Syntax:x >>> y
Method:T selfShiftRightUnsigned(L x, R y);
. -
SELF_SHIFTLEFT
Self-left-shift operator.
Syntax:x << y
Method:T selfShiftLeft(L x, R y);
. -
INCREMENT
Increment pseudo-operator.
No syntax, used as helper for the prefix and postfix versions of++
.- See Also:
-
DECREMENT
Decrement pseudo-operator.
No syntax, used as helper for the prefix and postfix versions of--
.- See Also:
-
INCREMENT_AND_GET
Prefix ++ operator, increments and returns the value after incrementing.
Syntax:++x
Method:T incrementAndGet(L x);
. -
GET_AND_INCREMENT
Postfix ++, increments and returns the value before incrementing.
Syntax:x++
Method:T getAndIncrement(L x);
. -
DECREMENT_AND_GET
Prefix --, decrements and returns the value after decrementing.
Syntax:--x
Method:T decrementAndGet(L x);
. -
GET_AND_DECREMENT
Postfix --, decrements and returns the value before decrementing.
Syntax:x--
Method:T getAndDecrement(L x);
. -
ASSIGN
Marker for side effect.
Returns this from 'self*' overload method to let the engine know the side effect has been performed and there is no need to assign the result. -
PROPERTY_GET
Property get operator as in: x.y.
Syntax:x.y
Method:Object propertyGet(L x, R y);
. -
PROPERTY_SET
Property set operator as in: x.y = z.
Syntax:x.y = z
Method:void propertySet(L x, R y, V z);
. -
ARRAY_GET
Array get operator as in: x[y].
Syntax:x.y
Method:Object arrayGet(L x, R y);
. -
ARRAY_SET
Array set operator as in: x[y] = z.
Syntax:x[y] = z
Method:void arraySet(L x, R y, V z);
. -
FOR_EACH
Iterator generator as in for(var x : y). If the returned Iterator is AutoCloseable, close will be called after the last execution of the loop block.
Syntax:for(var x : y){...}
Method:Iterator<Object> forEach(R y);
.- Since:
- 3.1
-
CONDITION
Test condition in if, for, while.
Method:boolean testCondition(R y);
.- Since:
- 3.3
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getArity
Gets this operator number of parameters.- Returns:
- the method arity
-
getBaseOperator
Gets the base operator.- Returns:
- the base operator
-
getMethodName
Gets this operator method name in a JexlArithmetic.- Returns:
- the method name
-
getOperatorSymbol
Gets this operator symbol.- Returns:
- the symbol
-