public final class MethodExecutor extends AbstractExecutor.Method
AbstractExecutor.Method.ParameterAbstractExecutor.Get, AbstractExecutor.Method, AbstractExecutor.Set| Modifier and Type | Field and Description |
|---|---|
private boolean |
isVarArgs
Whether this method handles varargs.
|
keymethod, objectClass, TRY_FAILED| Constructor and Description |
|---|
MethodExecutor(Introspector is,
java.lang.Object obj,
java.lang.String name,
java.lang.Object[] args)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
private static AbstractExecutor.Method.Parameter |
discover(Introspector is,
java.lang.Object obj,
java.lang.String method,
java.lang.Object[] args)
Discovers a method for a
MethodExecutor. |
java.lang.Object |
execute(java.lang.Object o,
java.lang.Object[] args)
Invokes the method to be executed.
|
protected java.lang.Object[] |
handleVarArg(java.lang.Class<?> type,
int index,
java.lang.Object[] actual)
Reassembles arguments if the method is a vararg method.
|
private static boolean |
isVarArgMethod(java.lang.reflect.Method m)
Determines if a method can accept a variable number of arguments.
|
java.lang.Object |
tryExecute(java.lang.String name,
java.lang.Object obj,
java.lang.Object[] args)
Tries to reuse this executor, checking that it is compatible with
the actual set of arguments.
|
getReturnType, getTargetProperty, invoke, tryInvokeequals, equals, getMethod, getMethodName, getTargetClass, hashCode, initMarker, isAlive, isCacheable, makeArgs, tryFailedclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitisCacheable, tryFailedpublic MethodExecutor(Introspector is, java.lang.Object obj, java.lang.String name, java.lang.Object[] args)
is - the introspector used to discover the methodobj - the object to find the method inname - the method nameargs - the method argumentspublic java.lang.Object execute(java.lang.Object o,
java.lang.Object[] args)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
execute in class AbstractExecutor.Methodo - the object to invoke the method uponargs - the method argumentsjava.lang.IllegalAccessException - Method is inaccessible.java.lang.reflect.InvocationTargetException - Method body throws an exception.public java.lang.Object tryExecute(java.lang.String name,
java.lang.Object obj,
java.lang.Object[] args)
tryExecute in class AbstractExecutor.Methodname - the method nameobj - the object to invoke the method uponargs - the method argumentsprivate static AbstractExecutor.Method.Parameter discover(Introspector is, java.lang.Object obj, java.lang.String method, java.lang.Object[] args)
MethodExecutor.
If the object is an array, an attempt will be made to find the
method in a List (see ArrayListWrapper)
If the object is a class, an attempt will be made to find the method as a static method of that class.
is - the introspector used to discover the methodobj - the object to introspectmethod - the name of the method to findargs - the method argumentsprotected java.lang.Object[] handleVarArg(java.lang.Class<?> type,
int index,
java.lang.Object[] actual)
type - The vararg class type (aka component type
of the expected array arg)index - The index of the vararg in the method declaration
(This will always be one less than the number of
expected arguments.)actual - The actual parameters being passed to this methodprivate static boolean isVarArgMethod(java.lang.reflect.Method m)
m - a the method to check