org.apache.commons.jexl3.introspection

## Interface JexlMethod

-     public interface JexlMethod

  Interface used for regular method invocation. Ex. `${foo.bar()}`
  Since:
    1.0

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `Class<?>` | `getReturnType()` returns the return type of the method invoked.
    `Object` | `invoke(Object obj, Object... params)` Invocation method, called when the method invocation should be performed and a value returned.
    `boolean` | `isCacheable()` Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.
    `boolean` | `tryFailed(Object rval)` Checks whether a tryInvoke return value indicates a failure or not.
    `Object` | `tryInvoke(String name, Object obj, Object... params)` Attempts to reuse this JexlMethod, checking that it is compatible with the actual set of arguments.

- - ### Method Detail

    - #### invoke

          Object invoke(Object obj,
                        Object... params)
                 throws Exception

      Invocation method, called when the method invocation should be performed and a value returned.
      Parameters:
        `obj` - the object
        `params` - method parameters.
      Returns:
        the result
      Throws:
        `Exception` - on any error.

    - #### tryInvoke

          Object tryInvoke(String name,
                           Object obj,
                           Object... params)
                    throws JexlException.TryFailed

      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.
      Parameters:
        `name` - the method name
        `obj` - 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`)

    - #### tryFailed

          boolean tryFailed(Object rval)

      Checks whether a tryInvoke return value indicates a failure or not.

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

      Parameters:
        `rval` - the value returned by tryInvoke
      Returns:
        true if tryInvoke failed, false otherwise

    - #### isCacheable

          boolean isCacheable()

      Specifies if this JexlMethod is cacheable and able to be reused for this class of object it was returned for.
      Returns:
        true if can be reused for this class, false if not

    - #### getReturnType

          Class<?> getReturnType()

      returns the return type of the method invoked.
      Returns:
        return type

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