Package org.apache.commons.jexl3

# Enum JexlOperator

java.lang.Object
java.lang.Enum<JexlOperator>
org.apache.commons.jexl3.JexlOperator

All Implemented Interfaces:
  `Serializable`, `Comparable<JexlOperator>`

public enum JexlOperator extends Enum<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

For side effect operators, operators that modify the left-hand size value (+=, -=, etc.), the user implemented overload methods may return:

- 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.

Note that side effect operators always return the left-hand side value (with an exception for postfix ++ and --).

Since:
  3.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `JexlOperator.Uberspect`
  Uberspect that solves and evaluates JexlOperator overloads.

- ## Enum Constant Summary

  Enum Constants
  Enum Constant
  Description
  `ADD`
  Add operator.
  `AND`
  Bitwise-and operator.
  `ARRAY_GET`
  Array get operator as in: x[y].
  `ARRAY_SET`
  Array set operator as in: x[y] = z.
  `ASSIGN`
  Deprecated.
  3.5.0
  `COMPARE`
  Compare overload as in compare(x, y).
  `COMPLEMENT`
  Complement operator.
  `CONDITION`
  Test condition in if, for, while.
  `CONTAINS`
  Contains operator.
  `DECREMENT`
  Decrement pseudo-operator.
  `DECREMENT_AND_GET`
  Prefix --, decrements and returns the value after decrementing.
  `DIVIDE`
  Divide operator.
  `EMPTY`
  Empty operator.
  `ENDSWITH`
  Ends-with operator.
  `EQ`
  Equals operator.
  `EQSTRICT`
  Equal-strict operator.
  `FOR_EACH`
  Iterator generator as in for(var x : y).
  `GET_AND_DECREMENT`
  Postfix --, decrements and returns the value before decrementing.
  `GET_AND_INCREMENT`
  Postfix ++, increments and returns the value before incrementing.
  `GT`
  Greater-than operator.
  `GTE`
  Greater-than-or-equal operator.
  `INCREMENT`
  Increment pseudo-operator.
  `INCREMENT_AND_GET`
  Prefix ++ operator, increments and returns the value after incrementing.
  `LT`
  Less-than operator.
  `LTE`
  Less-than-or-equal operator.
  `MOD`
  Modulo operator.
  `MULTIPLY`
  Multiply operator.
  `NEGATE`
  Negate operator.
  `NOT`
  Not operator.
  `NOT_CONTAINS`
  Not-Contains operator.
  `NOT_ENDSWITH`
  Not-Ends-With operator.
  `NOT_STARTSWITH`
  Not-Starts-With operator.
  `OR`
  Bitwise-or operator.
  `POSITIVIZE`
  Positivize operator.
  `PROPERTY_GET`
  Property get operator as in: x.y.
  `PROPERTY_SET`
  Property set operator as in: x.y = z.
  `SELF_ADD`
  Self-add operator.
  `SELF_AND`
  Self-and operator.
  `SELF_DIVIDE`
  Self-divide operator.
  `SELF_MOD`
  Self-modulo operator.
  `SELF_MULTIPLY`
  Self-multiply operator.
  `SELF_OR`
  Self-or operator.
  `SELF_SHIFTLEFT`
  Self-left-shift operator.
  `SELF_SHIFTRIGHT`
  Self-right-shift operator.
  `SELF_SHIFTRIGHTU`
  Self-right-shift unsigned operator.
  `SELF_SUBTRACT`
  Self-subtract operator.
  `SELF_XOR`
  Self-xor operator.
  `SHIFTLEFT`
  Bit-pattern left-shift operator.
  `SHIFTRIGHT`
  Bit-pattern right-shift operator.
  `SHIFTRIGHTU`
  Bit-pattern right-shift unsigned operator.
  `SIZE`
  Size operator.
  `STARTSWITH`
  Starts-with operator.
  `SUBTRACT`
  Subtract operator.
  `XOR`
  Bitwise-xor operator.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getArity()`
  Gets this operator number of parameters.
  `final JexlOperator`
  `getBaseOperator()`
  Gets the base operator.
  `final String`
  `getMethodName()`
  Gets this operator method name in a JexlArithmetic.
  `final String`
  `getOperatorSymbol()`
  Gets this operator symbol.
  `static JexlOperator`
  `valueOf(String name)`
  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.

  ### Methods inherited from class java.lang.Enum

  `clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`

  ### Methods inherited from class java.lang.Object

  `getClass, notify, notifyAll, wait, wait, wait`

- ## Enum Constant Details

  - ### ADD

    public static final JexlOperator ADD
    Add operator.
    Syntax: `x + y`
    Method: `T add(L x, R y);`.
    See Also:
      - `JexlArithmetic.add(Object, Object)`

  - ### SUBTRACT

    public static final JexlOperator SUBTRACT
    Subtract operator.
    Syntax: `x - y`
    Method: `T subtract(L x, R y);`.
    See Also:
      - `JexlArithmetic.subtract(Object, Object)`

  - ### MULTIPLY

    public static final JexlOperator MULTIPLY
    Multiply operator.
    Syntax: `x * y`
    Method: `T multiply(L x, R y);`.
    See Also:
      - `JexlArithmetic.multiply(Object, Object)`

  - ### DIVIDE

    public static final JexlOperator DIVIDE
    Divide operator.
    Syntax: `x / y`
    Method: `T divide(L x, R y);`.
    See Also:
      - `JexlArithmetic.divide(Object, Object)`

  - ### MOD

    public static final JexlOperator MOD
    Modulo operator.
    Syntax: `x % y`
    Method: `T mod(L x, R y);`.
    See Also:
      - `JexlArithmetic.mod(Object, Object)`

  - ### AND

    public static final JexlOperator AND
    Bitwise-and operator.
    Syntax: `x & y`
    Method: `T and(L x, R y);`.
    See Also:
      - `JexlArithmetic.and(Object, Object)`

  - ### OR

    public static final JexlOperator OR
    Bitwise-or operator.
    Syntax: `x | y`
    Method: `T or(L x, R y);`.
    See Also:
      - `JexlArithmetic.or(Object, Object)`

  - ### XOR

    public static final JexlOperator XOR
    Bitwise-xor operator.
    Syntax: `x ^ y`
    Method: `T xor(L x, R y);`.
    See Also:
      - `JexlArithmetic.xor(Object, Object)`

  - ### SHIFTRIGHT

    public static final JexlOperator SHIFTRIGHT
    Bit-pattern right-shift operator.
    Syntax: `x >> y`
    Method: `T rightShift(L x, R y);`.
    See Also:
      - `JexlArithmetic.shiftRight(Object, Object)`

  - ### SHIFTRIGHTU

    public static final JexlOperator SHIFTRIGHTU
    Bit-pattern right-shift unsigned operator.
    Syntax: `x >>> y`
    Method: `T rightShiftUnsigned(L x, R y);`.
    See Also:
      - `JexlArithmetic.shiftRightUnsigned(Object, Object)`

  - ### SHIFTLEFT

    public static final JexlOperator SHIFTLEFT
    Bit-pattern left-shift operator.
    Syntax: `x << y`
    Method: `T leftShift(L x, R y);`.
    See Also:
      - `JexlArithmetic.shiftLeft(Object, Object)`

  - ### EQ

    public static final JexlOperator EQ
    Equals operator.
    Syntax: `x == y`
    Method: `boolean equals(L x, R y);`.
    See Also:
      - `JexlArithmetic.equals(Object, Object)`

  - ### EQSTRICT

    public static final JexlOperator EQSTRICT
    Equal-strict operator.
    Syntax: `x === y`
    Method: `boolean strictEquals(L x, R y);`.
    See Also:
      - `JexlArithmetic.strictEquals(Object, Object)`

  - ### LT

    public static final JexlOperator LT
    Less-than operator.
    Syntax: `x < y`
    Method: `boolean lessThan(L x, R y);`.
    See Also:
      - `JexlArithmetic.lessThan(Object, Object)`

  - ### LTE

    public static final JexlOperator LTE
    Less-than-or-equal operator.
    Syntax: `x <= y`
    Method: `boolean lessThanOrEqual(L x, R y);`.
    See Also:
      - `JexlArithmetic.lessThanOrEqual(Object, Object)`

  - ### GT

    public static final JexlOperator GT
    Greater-than operator.
    Syntax: `x > y`
    Method: `boolean greaterThan(L x, R y);`.
    See Also:
      - `JexlArithmetic.greaterThan(Object, Object)`

  - ### GTE

    public static final JexlOperator GTE
    Greater-than-or-equal operator.
    Syntax: `x >= y`
    Method: `boolean greaterThanOrEqual(L x, R y);`.
    See Also:
      - `JexlArithmetic.greaterThanOrEqual(Object, Object)`

  - ### CONTAINS

    public static final JexlOperator CONTAINS
    Contains operator.
    Syntax: `x =~ y`
    Method: `boolean contains(L x, R y);`.
    See Also:
      - `JexlArithmetic.contains(Object, Object)`

  - ### STARTSWITH

    public static final JexlOperator STARTSWITH
    Starts-with operator.
    Syntax: `x =^ y`
    Method: `boolean startsWith(L x, R y);`.
    See Also:
      - `JexlArithmetic.startsWith(Object, Object)`

  - ### ENDSWITH

    public static final JexlOperator ENDSWITH
    Ends-with operator.
    Syntax: `x =$ y`
    Method: `boolean endsWith(L x, R y);`.
    See Also:
      - `JexlArithmetic.endsWith(Object, Object)`

  - ### NOT

    public static final JexlOperator NOT
    Not operator.
    Syntax: `!x`
    Method: `T not(L x);`.
    See Also:
      - `JexlArithmetic.not(Object)`

  - ### COMPLEMENT

    public static final JexlOperator COMPLEMENT
    Complement operator.
    Syntax: `~x`
    Method: `T complement(L x);`.
    See Also:
      - `JexlArithmetic.complement(Object)`

  - ### NEGATE

    public static final JexlOperator NEGATE
    Negate operator.
    Syntax: `-x`
    Method: `T negate(L x);`.
    See Also:
      - `JexlArithmetic.negate(Object)`

  - ### POSITIVIZE

    public static final JexlOperator POSITIVIZE
    Positivize operator.
    Syntax: `+x`
    Method: `T positivize(L x);`.
    See Also:
      - `JexlArithmetic.positivize(Object)`

  - ### EMPTY

    public static final JexlOperator EMPTY
    Empty operator.
    Syntax: `empty x` or `empty(x)`
    Method: `boolean empty(L x);`.
    See Also:
      - `JexlArithmetic.empty(Object)`

  - ### SIZE

    public static final JexlOperator SIZE
    Size operator.
    Syntax: `size x` or `size(x)`
    Method: `int size(L x);`.
    See Also:
      - `JexlArithmetic.size(Object)`

  - ### SELF_ADD

    public static final JexlOperator SELF_ADD
    Self-add operator.
    Syntax: `x += y`
    Method: `T selfAdd(L x, R y);`.

  - ### SELF_SUBTRACT

    public static final JexlOperator SELF_SUBTRACT
    Self-subtract operator.
    Syntax: `x -= y`
    Method: `T selfSubtract(L x, R y);`.

  - ### SELF_MULTIPLY

    public static final JexlOperator SELF_MULTIPLY
    Self-multiply operator.
    Syntax: `x *= y`
    Method: `T selfMultiply(L x, R y);`.

  - ### SELF_DIVIDE

    public static final JexlOperator SELF_DIVIDE
    Self-divide operator.
    Syntax: `x /= y`
    Method: `T selfDivide(L x, R y);`.

  - ### SELF_MOD

    public static final JexlOperator SELF_MOD
    Self-modulo operator.
    Syntax: `x %= y`
    Method: `T selfMod(L x, R y);`.

  - ### SELF_AND

    public static final JexlOperator SELF_AND
    Self-and operator.
    Syntax: `x &amp;= y`
    Method: `T selfAnd(L x, R y);`.

  - ### SELF_OR

    public static final JexlOperator SELF_OR
    Self-or operator.
    Syntax: `x |= y`
    Method: `T selfOr(L x, R y);`.

  - ### SELF_XOR

    public static final JexlOperator SELF_XOR
    Self-xor operator.
    Syntax: `x ^= y`
    Method: `T selfXor(L x, R y);`.

  - ### SELF_SHIFTRIGHT

    public static final JexlOperator SELF_SHIFTRIGHT
    Self-right-shift operator.
    Syntax: `x >>= y`
    Method: `T selfShiftRight(L x, R y);`.

  - ### SELF_SHIFTRIGHTU

    public static final JexlOperator SELF_SHIFTRIGHTU
    Self-right-shift unsigned operator.
    Syntax: `x >>> y`
    Method: `T selfShiftRightUnsigned(L x, R y);`.

  - ### SELF_SHIFTLEFT

    public static final JexlOperator SELF_SHIFTLEFT
    Self-left-shift operator.
    Syntax: `x << y`
    Method: `T selfShiftLeft(L x, R y);`.

  - ### INCREMENT

    public static final JexlOperator INCREMENT
    Increment pseudo-operator.
    No syntax, used as helper for the prefix and postfix versions of `++`.
    See Also:
      - `JexlArithmetic.increment(Object)`

  - ### DECREMENT

    public static final JexlOperator DECREMENT
    Decrement pseudo-operator.
    No syntax, used as helper for the prefix and postfix versions of `--`.
    See Also:
      - `JexlArithmetic.decrement(Object)`

  - ### INCREMENT_AND_GET

    public static final JexlOperator INCREMENT_AND_GET
    Prefix ++ operator, increments and returns the value after incrementing.
    Syntax: `++x`
    Method: `T incrementAndGet(L x);`.

  - ### GET_AND_INCREMENT

    public static final JexlOperator GET_AND_INCREMENT
    Postfix ++, increments and returns the value before incrementing.
    Syntax: `x++`
    Method: `T getAndIncrement(L x);`.

  - ### DECREMENT_AND_GET

    public static final JexlOperator DECREMENT_AND_GET
    Prefix --, decrements and returns the value after decrementing.
    Syntax: `--x`
    Method: `T decrementAndGet(L x);`.

  - ### GET_AND_DECREMENT

    public static final JexlOperator GET_AND_DECREMENT
    Postfix --, decrements and returns the value before decrementing.
    Syntax: `x--`
    Method: `T getAndDecrement(L x);`.

  - ### ASSIGN

    public static final JexlOperator ASSIGN
    Deprecated.
    3.5.0
    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

    public static final JexlOperator PROPERTY_GET
    Property get operator as in: x.y.
    Syntax: `x.y`
    Method: `Object propertyGet(L x, R y);`.

  - ### PROPERTY_SET

    public static final JexlOperator 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

    public static final JexlOperator ARRAY_GET
    Array get operator as in: x[y].
    Syntax: `x.y`
    Method: `Object arrayGet(L x, R y);`.

  - ### ARRAY_SET

    public static final JexlOperator 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

    public static final JexlOperator 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

    public static final JexlOperator CONDITION
    Test condition in if, for, while.
    Method: `boolean testCondition(R y);`.
    Since:
      3.3

  - ### COMPARE

    public static final JexlOperator COMPARE
    Compare overload as in compare(x, y).
    Method: `boolean compare(L x, R y);`.
    Since:
      3.5.0

  - ### NOT_CONTAINS

    public static final JexlOperator NOT_CONTAINS
    Not-Contains operator.

    Not overridable, calls !(contain(...))

  - ### NOT_STARTSWITH

    public static final JexlOperator NOT_STARTSWITH
    Not-Starts-With operator.

    Not overridable, calls !(startsWith(...))

  - ### NOT_ENDSWITH

    public static final JexlOperator NOT_ENDSWITH
    Not-Ends-With operator.

    Not overridable, calls !(endsWith(...))

- ## Method Details

  - ### values

    public static JexlOperator[] 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

    public static JexlOperator valueOf(String name)
    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 name
      `NullPointerException` - if the argument is null

  - ### getArity

    public int getArity()
    Gets this operator number of parameters.
    Returns:
      the method arity

  - ### getBaseOperator

    public final JexlOperator getBaseOperator()
    Gets the base operator.
    Returns:
      the base operator

  - ### getMethodName

    public final String getMethodName()
    Gets this operator method name in a JexlArithmetic.
    Returns:
      the method name

  - ### getOperatorSymbol

    public final String getOperatorSymbol()
    Gets this operator symbol.
    Returns:
      the symbol