public class MethodNameExecutor extends MethodExecutor
MethodExecutor.ExecutableMethod
executionObject
Constructor and Description |
---|
MethodNameExecutor(java.lang.Object executionObject,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodNameExecutor and search for operation methods.
|
MethodNameExecutor(java.lang.Object executionObject,
int nameArgIndex,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodNameExecutor and search for operation methods.
|
Modifier and Type | Method and Description |
---|---|
protected java.util.Map<java.lang.String,java.lang.reflect.Method> |
createRegisteredMethods(java.lang.Class<?> classToSearch,
boolean staticOnly,
java.lang.Class<?>[] methodPrototype)
Search the
classToSearch for methods that are matching the given
methodPrototype . |
java.util.List<java.lang.String> |
getDifferentiatingNames(java.lang.String regexp)
Returns the list of method names that this executor supports and
that match the specified regular expression.
|
static int |
getFirstStringClass(java.lang.Class<?>[] array)
Search array for first String class.
|
protected java.lang.reflect.Method |
getMethod(java.lang.Object[] arguments)
Returns the method that is appropriate for the provided arguments.
|
protected java.util.Collection<java.lang.reflect.Method> |
getRegisteredMethods()
Returns all methods that are registered within this executor.
|
static java.lang.String |
getStringObject(java.lang.Object[] array,
int index)
Get string from array at specified position.
|
backgroundExecute, backgroundExecute, backgroundExecute, execute, execute, printUsage, printUsage, printUsage
public MethodNameExecutor(java.lang.Object executionObject, int nameArgIndex, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
executionObject
- an instance of the object to execute the operations onmethodPrototype
- list of argument types for the registered methodsnameArgIndex
- the index of an argument from methodPrototype, which will hold the method namejava.lang.IllegalArgumentException
- if either the method prototype or named argument index is invalid or the executionObject is nullpublic MethodNameExecutor(java.lang.Object executionObject, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
first string class
in the given methodPrototype
is expected to hold the method name.executionObject
- an instance of the object to execute the operations onmethodPrototype
- list of argument types for the registered methodsjava.lang.IllegalArgumentException
- if either the method prototype or named argument index is invalid or the executionObject is nullprotected final java.util.Map<java.lang.String,java.lang.reflect.Method> createRegisteredMethods(java.lang.Class<?> classToSearch, boolean staticOnly, java.lang.Class<?>[] methodPrototype)
classToSearch
for methods that are matching the given
methodPrototype
. The search is recursive starting from the
top-level (excluding Object
) class to classToSearch
.classToSearch
- the class to searchstaticOnly
- the flag if only static methods are addedmethodPrototype
- the prototype of the methods to search forpublic static int getFirstStringClass(java.lang.Class<?>[] array)
array
- the array to searchpublic static java.lang.String getStringObject(java.lang.Object[] array, int index) throws java.lang.ClassCastException, java.lang.IndexOutOfBoundsException
array
- the array of argumentsindex
- the index of the argument to getjava.lang.ClassCastException
- if the array item at the specified position is not a stringjava.lang.IndexOutOfBoundsException
- if the specified position is invalidprotected java.lang.reflect.Method getMethod(java.lang.Object[] arguments) throws java.lang.NoSuchMethodException
MethodExecutor
getMethod
in class MethodExecutor
arguments
- the arguments for the methodjava.lang.NoSuchMethodException
- if there is no method that can process the provided arguments in this executorpublic java.util.List<java.lang.String> getDifferentiatingNames(java.lang.String regexp)
regexp
- the regular expression for matching method namesprotected java.util.Collection<java.lang.reflect.Method> getRegisteredMethods()
MethodExecutor
getRegisteredMethods
in class MethodExecutor