Class 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
  • Field Details

    • property

      private final Object property
      The property, may be null.
  • Constructor Details

    • DuckGetExecutor

      private DuckGetExecutor(Class<?> clazz, Method method, Object identifier)
      Creates an instance.
      Parameters:
      clazz - he class the get method applies to
      method - the method held by this executor
      identifier - the property to get
  • Method Details

    • 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()
      Description copied from class: AbstractExecutor
      Gets the property targeted by this executor.
      Overrides:
      getTargetProperty in class AbstractExecutor
      Returns:
      the target property
    • invoke

      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.