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 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
  Since:
    3.0

- - ### Enum Constant Summary

    Enum Constants
    Enum Constant and 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` Marker for side effect.
    `COMPLEMENT` Complement operator.
    `CONTAINS` Contains operator.
    `DIVIDE` Divide operator.
    `EMPTY` Empty operator.
    `ENDSWITH` Ends-with operator.
    `EQ` Equals operator.
    `FOR_EACH` Iterator generator as in for(var x : y).
    `GT` Greater-than operator.
    `GTE` Greater-than-or-equal operator.
    `LT` Less-than operator.
    `LTE` Less-than-or-equal operator.
    `MOD` Modulo operator.
    `MULTIPLY` Multiply operator.
    `NEGATE` Negate operator.
    `NOT` Not 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_SUBTRACT` Self-subtract operator.
    `SELF_XOR` Self-xor operator.
    `SIZE` Size operator.
    `STARTSWITH` Starts-with operator.
    `SUBTRACT` Subtract operator.
    `XOR` Bitwise-xor operator.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `getArity()` Gets this operator number of parameters.
    `JexlOperator` | `getBaseOperator()` Gets the base operator.
    `String` | `getMethodName()` Gets this operator method name in a JexlArithmetic.
    `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

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

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

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

- - ### Enum Constant Detail

    - #### ADD

          public static final JexlOperator ADD

      Add operator.
      Syntax: `x + y`
      Method: `T add(L x, R y);`.
      See Also:
        `JexlArithmetic.add(java.lang.Object, java.lang.Object)`

    - #### SUBTRACT

          public static final JexlOperator SUBTRACT

      Subtract operator.
      Syntax: `x - y`
      Method: `T subtract(L x, R y);`.
      See Also:
        `JexlArithmetic.subtract(java.lang.Object, java.lang.Object)`

    - #### MULTIPLY

          public static final JexlOperator MULTIPLY

      Multiply operator.
      Syntax: `x * y`
      Method: `T multiply(L x, R y);`.
      See Also:
        `JexlArithmetic.multiply(java.lang.Object, java.lang.Object)`

    - #### DIVIDE

          public static final JexlOperator DIVIDE

      Divide operator.
      Syntax: `x / y`
      Method: `T divide(L x, R y);`.
      See Also:
        `JexlArithmetic.divide(java.lang.Object, java.lang.Object)`

    - #### MOD

          public static final JexlOperator MOD

      Modulo operator.
      Syntax: `x % y`
      Method: `T mod(L x, R y);`.
      See Also:
        `JexlArithmetic.mod(java.lang.Object, java.lang.Object)`

    - #### AND

          public static final JexlOperator AND

      Bitwise-and operator.
      Syntax: `x & y`
      Method: `T and(L x, R y);`.
      See Also:
        `JexlArithmetic.and(java.lang.Object, java.lang.Object)`

    - #### OR

          public static final JexlOperator OR

      Bitwise-or operator.
      Syntax: `x | y`
      Method: `T or(L x, R y);`.
      See Also:
        `JexlArithmetic.or(java.lang.Object, java.lang.Object)`

    - #### XOR

          public static final JexlOperator XOR

      Bitwise-xor operator.
      Syntax: `x ^ y`
      Method: `T xor(L x, R y);`.
      See Also:
        `JexlArithmetic.xor(java.lang.Object, java.lang.Object)`

    - #### EQ

          public static final JexlOperator EQ

      Equals operator.
      Syntax: `x == y`
      Method: `boolean equals(L x, R y);`.
      See Also:
        `JexlArithmetic.equals(java.lang.Object, java.lang.Object)`

    - #### LT

          public static final JexlOperator LT

      Less-than operator.
      Syntax: `x < y`
      Method: `boolean lessThan(L x, R y);`.
      See Also:
        `JexlArithmetic.lessThan(java.lang.Object, java.lang.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(java.lang.Object, java.lang.Object)`

    - #### GT

          public static final JexlOperator GT

      Greater-than operator.
      Syntax: `x > y`
      Method: `boolean greaterThan(L x, R y);`.
      See Also:
        `JexlArithmetic.greaterThan(java.lang.Object, java.lang.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(java.lang.Object, java.lang.Object)`

    - #### CONTAINS

          public static final JexlOperator CONTAINS

      Contains operator.
      Syntax: `x =~ y`
      Method: `boolean contains(L x, R y);`.
      See Also:
        `JexlArithmetic.contains(java.lang.Object, java.lang.Object)`

    - #### STARTSWITH

          public static final JexlOperator STARTSWITH

      Starts-with operator.
      Syntax: `x =^ y`
      Method: `boolean startsWith(L x, R y);`.
      See Also:
        `JexlArithmetic.startsWith(java.lang.Object, java.lang.Object)`

    - #### ENDSWITH

          public static final JexlOperator ENDSWITH

      Ends-with operator.
      Syntax: `x =$ y`
      Method: `boolean endsWith(L x, R y);`.
      See Also:
        `JexlArithmetic.endsWith(java.lang.Object, java.lang.Object)`

    - #### NOT

          public static final JexlOperator NOT

      Not operator.
      Syntax: `!x`
      Method: `T not(L x);`.
      See Also:
        `JexlArithmetic.not(java.lang.Object)`

    - #### COMPLEMENT

          public static final JexlOperator COMPLEMENT

      Complement operator.
      Syntax: `~x`
      Method: `T complement(L x);`.
      See Also:
        `JexlArithmetic.complement(java.lang.Object)`

    - #### NEGATE

          public static final JexlOperator NEGATE

      Negate operator.
      Syntax: `-x`
      Method: `T negate(L x);`.
      See Also:
        `JexlArithmetic.negate(java.lang.Object)`

    - #### POSITIVIZE

          public static final JexlOperator POSITIVIZE

      Positivize operator.
      Syntax: `+x`
      Method: `T positivize(L x);`.
      See Also:
        `JexlArithmetic.positivize(java.lang.Object)`

    - #### EMPTY

          public static final JexlOperator EMPTY

      Empty operator.
      Syntax: `empty x` or `empty(x)`
      Method: `boolean empty(L x);`.
      See Also:
        `JexlArithmetic.empty(java.lang.Object)`

    - #### SIZE

          public static final JexlOperator SIZE

      Size operator.
      Syntax: `size x` or `size(x)`
      Method: `int size(L x);`.
      See Also:
        `JexlArithmetic.size(java.lang.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 &= 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);`.

    - #### ASSIGN

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

          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

  - ### Method Detail

    - #### values

          public static JexlOperator[] values()

      Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:

          for (JexlOperator c : JexlOperator.values())
              System.out.println(c);

      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

    - #### getOperatorSymbol

          public final String getOperatorSymbol()

      Gets this operator symbol.
      Returns:
        the symbol

    - #### getMethodName

          public final String getMethodName()

      Gets this operator method name in a JexlArithmetic.
      Returns:
        the method name

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

Copyright © 2001–2021 The Apache Software Foundation. All rights reserved.