Class DuckGetExecutor
- java.lang.Object
-
- org.apache.commons.jexl3.internal.introspection.AbstractExecutor
-
- 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/interfaces inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
AbstractExecutor.Get, AbstractExecutor.Method, AbstractExecutor.Set
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
property
The property, may be null.-
Fields inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
method, objectClass, TRY_FAILED
-
-
Constructor Summary
Constructors Modifier Constructor Description private
DuckGetExecutor(java.lang.Class<?> clazz, java.lang.reflect.Method method, java.lang.Object identifier)
Creates an instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DuckGetExecutor
discover(Introspector is, java.lang.Class<?> clazz, java.lang.Object identifier)
Attempts to discover a DuckGetExecutor.java.lang.Object
getTargetProperty()
Gets the property targeted by this executor.java.lang.Object
invoke(java.lang.Object obj)
Method used to get the property value of an object.java.lang.Object
tryInvoke(java.lang.Object obj, java.lang.Object key)
Attempts to reuse this JexlPropertyGet, checking that it is compatible with the actual set of arguments.-
Methods inherited from class org.apache.commons.jexl3.internal.introspection.AbstractExecutor
castInteger, castString, classOf, equals, equals, getMethod, getMethodName, getTargetClass, hashCode, initMarker, isAlive, isCacheable, makeArgs, tryFailed
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.jexl3.introspection.JexlPropertyGet
isCacheable, tryFailed
-
-
-
-
Method Detail
-
discover
public static DuckGetExecutor discover(Introspector is, java.lang.Class<?> clazz, java.lang.Object identifier)
Attempts to discover a DuckGetExecutor.- Parameters:
is
- the introspectorclazz
- the class to find the get method fromidentifier
- the key to use as an argument to the get method- Returns:
- the executor if found, null otherwise
-
getTargetProperty
public java.lang.Object getTargetProperty()
Description copied from class:AbstractExecutor
Gets the property targeted by this executor.- Overrides:
getTargetProperty
in classAbstractExecutor
- Returns:
- the target property
-
invoke
public java.lang.Object invoke(java.lang.Object obj) throws java.lang.IllegalAccessException, java.lang.reflect.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:
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
-
tryInvoke
public java.lang.Object tryInvoke(java.lang.Object obj, java.lang.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 uponkey
- 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.
-
-