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

  • Constructor Details

  • Method Details

    • getReturnType

      public Class<?> getReturnType()
      Description copied from interface: JexlMethod
      returns the return type of the method invoked.
      Specified by:
      getReturnType in interface JexlMethod
      Returns:
      return type
    • invoke

      public Object invoke(Object arithmetic, Object... params) throws Exception
      Description copied from interface: JexlMethod
      Invocation method, called when the method invocation should be performed and a value returned.
      Specified by:
      invoke in interface JexlMethod
      Parameters:
      arithmetic - The object
      params - method parameters.
      Returns:
      The result
      Throws:
      Exception - on any error.
    • isCacheable

      public boolean isCacheable()
      Description copied from interface: JexlMethod
      Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.
      Specified by:
      isCacheable in interface JexlMethod
      Returns:
      true if can be reused for this class, false if not
    • tryFailed

      public boolean tryFailed(Object rval)
      Description copied from interface: JexlMethod
      Checks whether a tryInvoke return value indicates a failure or not.

      Usage is : Object r = tryInvoke(...); if (tryFailed(r) {...} else {...}

      Specified by:
      tryFailed in interface JexlMethod
      Parameters:
      rval - The value returned by tryInvoke
      Returns:
      true if tryInvoke failed, false otherwise
    • tryInvoke

      public Object tryInvoke(String name, Object arithmetic, Object... params) throws JexlException.TryFailed
      Description copied from interface: JexlMethod
      Attempts 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:
      tryInvoke in interface JexlMethod
      Parameters:
      name - The method name
      arithmetic - The object to invoke the method upon
      params - 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