org.apache.commons.jexl3.internal.introspection

## Class DuckGetExecutor

- java.lang.Object
- - org.apache.commons.jexl3.internal.introspection.AbstractExecutor.Get
  - - org.apache.commons.jexl3.internal.introspection.DuckGetExecutor

- All Implemented Interfaces:
    JexlPropertyGet

      public final class DuckGetExecutor
      extends AbstractExecutor.Get

  Specialized executor to get a property from an object.

  Duck as in duck-typing for an interface like: `interface Get { Object get(Object key); }`

  Since:
    2.0

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AbstractExecutor.Get` Abstract class that is used to execute an arbitrary 'get' method.
    `static class` | `AbstractExecutor.Method` Abstract class that is used to execute an arbitrary method.
    `static class` | `AbstractExecutor.Set` Abstract class that is used to execute an arbitrary 'set' method.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static Object` | `TRY_FAILED` A marker for invocation failures in tryInvoke.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static DuckGetExecutor` | `discover(Introspector is, Class<?> clazz, Object identifier)` Attempts to discover a DuckGetExecutor.
    `boolean` | `equals(org.apache.commons.jexl3.internal.introspection.AbstractExecutor arg)` Indicates whether some other executor is equivalent to this one.
    `boolean` | `equals(Object obj)`
    `Method` | `getMethod()` Gets the method to be executed or used as a marker.
    `String` | `getMethodName()` Gets the method name used.
    `Class<?>` | `getTargetClass()` Gets the object class targeted by this executor.
    `Object` | `getTargetProperty()` Gets the property targeted by this executor.
    `int` | `hashCode()`
    `Object` | `invoke(Object obj)` Method used to get the property value of an object.
    `boolean` | `isAlive()` Tell whether the executor is alive by looking at the value of the method.
    `boolean` | `isCacheable()` Specifies if this executor is cacheable and able to be reused for this class of object it was returned for.
    `boolean` | `tryFailed(Object exec)` Checks whether a tryExecute failed or not.
    `Object` | `tryInvoke(Object obj, Object key)` Attempts to reuse this JexlPropertyGet, checking that it is compatible with the actual set of arguments.

    - ### Methods inherited from class java.lang.Object

      `getClass, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.jexl3.introspection.JexlPropertyGet

      `isCacheable, tryFailed`

- - ### Field Detail

    - #### TRY_FAILED

          public static final Object TRY_FAILED

      A marker for invocation failures in tryInvoke.

  - ### Method Detail

    - #### discover

          public static DuckGetExecutor discover(Introspector is,
                                                 Class<?> clazz,
                                                 Object identifier)

      Attempts to discover a DuckGetExecutor.
      Parameters:
        `is` - the introspector
        `clazz` - the class to find the get method from
        `identifier` - the key to use as an argument to the get method
      Returns:
        the executor if found, null otherwise

    - #### getTargetProperty

          public Object getTargetProperty()

      Gets the property targeted by this executor.
      Returns:
        the target property

    - #### invoke

          public Object invoke(Object obj)
                        throws IllegalAccessException,
                               InvocationTargetException

      Description copied from interface: `JexlPropertyGet`
      Method used to get the property value of an object.
      Parameters:
        `obj` - the object to get the property value from.
      Returns:
        the property value.
      Throws:
        `IllegalAccessException`
        `InvocationTargetException`

    - #### tryInvoke

          public Object tryInvoke(Object obj,
                                  Object key)

      Description copied from interface: `JexlPropertyGet`
      Attempts to reuse this JexlPropertyGet, checking that it is compatible with the actual set of arguments.
      Parameters:
        `obj` - the object to invoke the property get upon
        `key` - the property key to get
      Returns:
        the result of the method invocation that should be checked by tryFailed to determine if it succeeded or failed.

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### equals

          public boolean equals(org.apache.commons.jexl3.internal.introspection.AbstractExecutor arg)

      Indicates whether some other executor is equivalent to this one.
      Parameters:
        `arg` - the other executor to check
      Returns:
        true if both executors are equivalent, false otherwise

    - #### isAlive

          public final boolean isAlive()

      Tell whether the executor is alive by looking at the value of the method.
      Returns:
        boolean Whether the executor is alive.

    - #### isCacheable

          public boolean isCacheable()

      Specifies if this executor 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

    - #### getMethod

          public final Method getMethod()

      Gets the method to be executed or used as a marker.
      Returns:
        Method The method used by execute in derived classes.

    - #### getTargetClass

          public final Class<?> getTargetClass()

      Gets the object class targeted by this executor.
      Returns:
        the target object class

    - #### getMethodName

          public final String getMethodName()

      Gets the method name used.
      Returns:
        method name

    - #### tryFailed

          public final boolean tryFailed(Object exec)

      Checks whether a tryExecute failed or not.
      Parameters:
        `exec` - the value returned by tryExecute
      Returns:
        true if tryExecute failed, false otherwise

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