Interface JexlOperator.Uberspect
-
- All Superinterfaces:
JexlArithmetic.Uberspect
- All Known Implementing Classes:
Operator
- Enclosing class:
- JexlOperator
public static interface JexlOperator.Uberspect extends JexlArithmetic.Uberspect
Uberspect that solves and evaluates JexlOperator overloads.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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description booleancontains(JexlCache.Reference node, JexlOperator operator, java.lang.Object left, java.lang.Object right)The 'match'/'in' operator implementation.java.lang.Objectempty(JexlCache.Reference node, java.lang.Object object)Check for emptiness of various types: Collection, Array, Map, String, and anything that has a boolean isEmpty() method.booleanendsWith(JexlCache.Reference node, JexlOperator operator, java.lang.Object left, java.lang.Object right)The 'endsWith' operator implementation.java.lang.Objectsize(JexlCache.Reference node, java.lang.Object object)Calculate thesizeof various types: Collection, Array, Map, String, and anything that has an int size() method.booleanstartsWith(JexlCache.Reference node, JexlOperator operator, java.lang.Object left, java.lang.Object right)The 'startsWith' operator implementation.java.lang.ObjecttryAssignOverload(JexlCache.Reference node, JexlOperator operator, java.util.function.Consumer<java.lang.Object> assign, java.lang.Object... args)Evaluates an assign operator.java.lang.ObjecttryOverload(JexlCache.Reference reference, JexlOperator operator, java.lang.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 Detail
-
tryOverload
java.lang.Object tryOverload(JexlCache.Reference reference, JexlOperator operator, java.lang.Object... args)
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
java.lang.Object tryAssignOverload(JexlCache.Reference node, JexlOperator operator, java.util.function.Consumer<java.lang.Object> assign, java.lang.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
java.lang.Object size(JexlCache.Reference node, java.lang.Object object)
Calculate thesizeof 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
java.lang.Object empty(JexlCache.Reference node, java.lang.Object object)
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
boolean contains(JexlCache.Reference node, JexlOperator operator, java.lang.Object left, java.lang.Object right)
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 !~right- the left operandleft- the right operand- Returns:
- true if left matches right, false otherwise
-
startsWith
boolean startsWith(JexlCache.Reference node, JexlOperator operator, java.lang.Object left, java.lang.Object right)
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
boolean endsWith(JexlCache.Reference node, JexlOperator operator, java.lang.Object left, java.lang.Object right)
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
-
-