Class Operator.CompareMethod
- java.lang.Object
-
- org.apache.commons.jexl3.internal.Operator.CompareMethod
-
- All Implemented Interfaces:
JexlMethod
- Direct Known Subclasses:
Operator.AntiCompareMethod
- Enclosing class:
- Operator
private static class Operator.CompareMethod extends java.lang.Object implements JexlMethod
Delegates a comparison operator to a compare method. The expected signature of the derived JexlArithmetic method is: int compare(L left, R right);
-
-
Field Summary
Fields Modifier and Type Field Description protected JexlMethodcompareprotected JexlOperatoroperator
-
Constructor Summary
Constructors Constructor Description CompareMethod(JexlOperator op, JexlMethod m)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Class<?>getReturnType()returns the return type of the method invoked.java.lang.Objectinvoke(java.lang.Object arithmetic, java.lang.Object... params)Invocation method, called when the method invocation should be performed and a value returned.booleanisCacheable()Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.protected booleanoperate(int cmp)From compare() int result to operator boolean result.booleantryFailed(java.lang.Object rval)Checks whether a tryInvoke return value indicates a failure or not.java.lang.ObjecttryInvoke(java.lang.String name, java.lang.Object arithmetic, java.lang.Object... params)Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments.
-
-
-
Field Detail
-
operator
protected final JexlOperator operator
-
compare
protected final JexlMethod compare
-
-
Constructor Detail
-
CompareMethod
CompareMethod(JexlOperator op, JexlMethod m)
-
-
Method Detail
-
getReturnType
public java.lang.Class<?> getReturnType()
Description copied from interface:JexlMethodreturns the return type of the method invoked.- Specified by:
getReturnTypein interfaceJexlMethod- Returns:
- return type
-
invoke
public java.lang.Object invoke(java.lang.Object arithmetic, java.lang.Object... params) throws java.lang.ExceptionDescription copied from interface:JexlMethodInvocation method, called when the method invocation should be performed and a value returned.- Specified by:
invokein interfaceJexlMethod- Parameters:
arithmetic- the objectparams- method parameters.- Returns:
- the result
- Throws:
java.lang.Exception- on any error.
-
isCacheable
public boolean isCacheable()
Description copied from interface:JexlMethodSpecifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.- Specified by:
isCacheablein interfaceJexlMethod- Returns:
- true if can be reused for this class, false if not
-
tryFailed
public boolean tryFailed(java.lang.Object rval)
Description copied from interface:JexlMethodChecks whether a tryInvoke return value indicates a failure or not.Usage is :
Object r = tryInvoke(...); if (tryFailed(r) {...} else {...}- Specified by:
tryFailedin interfaceJexlMethod- Parameters:
rval- the value returned by tryInvoke- Returns:
- true if tryInvoke failed, false otherwise
-
tryInvoke
public java.lang.Object tryInvoke(java.lang.String name, java.lang.Object arithmetic, java.lang.Object... params) throws JexlException.TryFailedDescription copied from interface:JexlMethodAttempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments. Related to isCacheable since this method is often used with cached JexlMethod instances.- Specified by:
tryInvokein interfaceJexlMethod- Parameters:
name- the method namearithmetic- the object to invoke the method uponparams- the method arguments- Returns:
- the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.
- Throws:
JexlException.TryFailed- if the underlying method was invoked but threw an exception (InvocationTargetException)
-
operate
protected boolean operate(int cmp)
From compare() int result to operator boolean result.- Parameters:
cmp- the compare result- Returns:
- the operator applied
-
-