Interface JexlOperator.Uberspect
- All Superinterfaces:
JexlArithmetic.Uberspect
- Enclosing class:
JexlOperator
This is used by the interpreter to find and execute operator overloads implemented in a derived JexlArithmetic - or in some cases, as methods of the left argument type (contains, size, ...).
This also allows reusing the core logic when extending the applicative type-system; for
instance, implementing a Comparator class that calls compare
(operator.tryOverload(this, JexlOperator.COMPARE, left, right)
, etc.
- Since:
- 3.5.0
-
Method Summary
Modifier and TypeMethodDescriptionboolean
contains
(JexlCache.Reference node, JexlOperator operator, Object left, Object right) The 'match'/'in' operator implementation.empty
(JexlCache.Reference node, Object object) Check for emptiness of various types: Collection, Array, Map, String, and anything that has a boolean isEmpty() method.boolean
endsWith
(JexlCache.Reference node, JexlOperator operator, Object left, Object right) The 'endsWith' operator implementation.size
(JexlCache.Reference node, Object object) Calculate thesize
of various types: Collection, Array, Map, String, and anything that has an int size() method.boolean
startsWith
(JexlCache.Reference node, JexlOperator operator, Object left, Object right) The 'startsWith' operator implementation.tryAssignOverload
(JexlCache.Reference node, JexlOperator operator, Consumer<Object> assign, Object... args) Evaluates an assign operator.tryOverload
(JexlCache.Reference reference, JexlOperator operator, Object... args) Try to find the most specific method and evaluate an operator.Methods inherited from interface org.apache.commons.jexl3.JexlArithmetic.Uberspect
getOperator, overloads
-
Method Details
-
tryOverload
Try to find the most specific method and evaluate an operator.This method does not call
JexlArithmetic.Uberspect.overloads(JexlOperator)
and shall not be called with an assignment operator; usetryAssignOverload(JexlCache.Reference, JexlOperator, Consumer, Object...)
in that case.- Parameters:
reference
- an optional reference caching resolved method or failing signatureoperator
- the operatorargs
- the arguments- Returns:
- TRY_FAILED if no specific method could be found, the evaluation result otherwise
-
tryAssignOverload
Object tryAssignOverload(JexlCache.Reference node, JexlOperator operator, Consumer<Object> assign, Object... args) Evaluates an assign operator.This takes care of finding and caching the operator method when appropriate. If an overloads returns a value not-equal to TRY_FAILED, it means the side-effect is complete. Otherwise,
a += b <=> a = a + b
- Parameters:
node
- an optional reference caching resolved method or failing signatureoperator
- the operatorassign
- the actual function that performs the side effectargs
- the arguments, the first one being the target of assignment- Returns:
- JexlEngine.TRY_FAILED if no operation was performed, the value to use as the side effect argument otherwise
-
size
Calculate thesize
of various types: Collection, Array, Map, String, and anything that has an int size() method.Seeks an overload or use the default arithmetic implementation.
Note that the result may not be an integer.
- Parameters:
node
- an optional reference caching resolved method or failing signatureobject
- the object to get the size of- Returns:
- the evaluation result
-
empty
Check for emptiness of various types: Collection, Array, Map, String, and anything that has a boolean isEmpty() method.Seeks an overload or use the default arithmetic implementation.
Note that the result may not be a boolean.
- Parameters:
node
- the node holding the objectobject
- the object to check the emptiness of- Returns:
- the evaluation result
-
contains
The 'match'/'in' operator implementation.Seeks an overload or use the default arithmetic implementation.
Note that 'x in y' or 'x matches y' means 'y contains x' ; the JEXL operator arguments order syntax is the reverse of this method call.
- Parameters:
node
- an optional reference caching resolved method or failing signatureoperator
- the calling operator, =~ or !~left
- the right operandright
- the left operand- Returns:
- true if left matches right, false otherwise
-
startsWith
The 'startsWith' operator implementation.Seeks an overload or use the default arithmetic implementation.
- Parameters:
node
- an optional reference caching resolved method or failing signatureoperator
- the calling operator, $= or $!left
- the left operandright
- the right operand- Returns:
- true if left starts with right, false otherwise
-
endsWith
The 'endsWith' operator implementation.Seeks an overload or use the default arithmetic implementation.
- Parameters:
node
- an optional reference caching resolved method or failing signatureoperator
- the calling operator, ^= or ^!left
- the left operandright
- the right operand- Returns:
- true if left ends with right, false otherwise
-