public class MethodClassExecutor extends MethodExecutor
MethodExecutor.ExecutableMethod
Modifier and Type | Field and Description |
---|---|
protected int |
differentiateByArgNo
Index of the argument in the method prototype, which is used to distinguish between the methods
|
protected java.util.Map<java.lang.Class<?>,java.lang.reflect.Method> |
registeredMethods
The table of found operation methods
|
executionObject
Constructor and Description |
---|
MethodClassExecutor(java.lang.Object executionObject,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodExecutor and search for operation methods.
|
MethodClassExecutor(java.lang.Object executionObject,
java.lang.Class<?> inheritedMethods,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodExecutor and search for operation methods.
|
MethodClassExecutor(java.lang.Object executionObject,
int differentiateByArgNo,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodExecutor and search for operation methods.
|
MethodClassExecutor(java.lang.Object executionObject,
int differentiateByArgNo,
java.lang.String methodNames,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodClassExecutor and search for operation methods
Public methods from the whole object's hierarchy are executed.
|
MethodClassExecutor(java.lang.Object executionObject,
int differentiateByArgNo,
java.lang.String methodNames,
int modifiers,
java.lang.Class<?> inheritedMethods,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodClassExecutor and search for operation methods
|
MethodClassExecutor(java.lang.Object executionObject,
java.lang.String methodNames,
java.lang.Class<?>... methodPrototype)
Create new instance of MethodExecutor and search for operation methods.
|
Modifier and Type | Method and Description |
---|---|
protected static java.util.Collection<java.lang.reflect.Method> |
getClassMethods(java.lang.Class<?> readClass,
int modifiers,
java.lang.Class<?> readSuperclass)
Returns all methods from the specified class that have the modifiers.
|
<E> java.util.List<java.lang.Class<? extends E>> |
getDifferentiatingClasses(java.lang.Class<? extends E> subclassesToSearch)
Returns the list of classes that this executor recognizes and can execute their associated method.
|
<E> java.util.List<java.lang.Class<? extends E>> |
getDifferentiatingClasses(java.lang.Class<? extends E> subclassesToSearch,
int modifiers)
Returns the list of classes that this executor recognizes and can execute their associated method.
|
protected java.lang.reflect.Method |
getMethod(java.lang.Class<?> key,
boolean trySuperClasses)
Returns the stored method according to the the specified class.
|
protected java.lang.reflect.Method |
getMethod(java.lang.Object[] arguments)
Returns a proper execution method for provided arguments.
|
protected java.util.Collection<java.lang.reflect.Method> |
getRegisteredMethods()
Returns the list of classes that this executor recognizes and can execute their associated method.
|
backgroundExecute, backgroundExecute, backgroundExecute, execute, execute, printUsage, printUsage, printUsage
protected transient java.util.Map<java.lang.Class<?>,java.lang.reflect.Method> registeredMethods
protected final int differentiateByArgNo
public MethodClassExecutor(java.lang.Object executionObject, int differentiateByArgNo, java.lang.String methodNames, int modifiers, java.lang.Class<?> inheritedMethods, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
executionObject
- an instance of the object to execute the operations ondifferentiateByArgNo
- the index of an argument from methodPrototype, which will destinguish the methodsmethodNames
- the name which all the methods must matchmodifiers
- specify or'ed values of Modifier
that the method must have setinheritedMethods
- if null only methods declared in the executionObject
are loaded.
Otherwise, methods from all superclasses up to class inheritedMethods
exclusive are loaded.methodPrototype
- list of argument types for the registered methodsjava.lang.IllegalArgumentException
- if either the method prototype or differentiating argument index is invalid or the executionObject is nullpublic MethodClassExecutor(java.lang.Object executionObject, int differentiateByArgNo, java.lang.String methodNames, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
executionObject
- an instance of the object to execute the operations ondifferentiateByArgNo
- the index of an argument from methodPrototype, which will destinguish the methodsmethodNames
- the name which all the methods must matchmethodPrototype
- list of argument types for the registered methodsjava.lang.IllegalArgumentException
- if the differentiating argument index is invalid or the executionObject is nullpublic MethodClassExecutor(java.lang.Object executionObject, java.lang.Class<?> inheritedMethods, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
executionObject
- an instance of the object to execute the operations oninheritedMethods
- if null only methods declared in the executionObject
are loaded.
Otherwise, methods from all superclasses up to class inheritedMethods
exclusive are loaded.methodPrototype
- list of argument types for the registered methodsjava.lang.IllegalArgumentException
- if the method prototype has no arguments or the executionObject is nullpublic MethodClassExecutor(java.lang.Object executionObject, 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 methodsjava.lang.IllegalArgumentException
- if the method prototype has no arguments or the executionObject is nullpublic MethodClassExecutor(java.lang.Object executionObject, int differentiateByArgNo, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
executionObject
- an instance of the object to execute the operations ondifferentiateByArgNo
- the index of an argument from methodPrototype, which will destinguish the methodsmethodPrototype
- list of argument types for the registered methodsjava.lang.IllegalArgumentException
- if the differentiating argument index is invalid or the executionObject is nullpublic MethodClassExecutor(java.lang.Object executionObject, java.lang.String methodNames, java.lang.Class<?>... methodPrototype) throws java.lang.IllegalArgumentException
executionObject
- an instance of the object to execute the operations onmethodNames
- the name which all the methods must matchmethodPrototype
- list of argument types for the registered methodsjava.lang.IllegalArgumentException
- if the method prototype has no arguments or the executionObject is nullprotected static java.util.Collection<java.lang.reflect.Method> getClassMethods(java.lang.Class<?> readClass, int modifiers, java.lang.Class<?> readSuperclass)
readClass
- the class for which the methods are readmodifiers
- or'ed together (see Modifier
for their list). All set modifiers must be present
for a specific method except for the access modifiers. For example, value
Modifier.PROTECTED
| Modifier.PUBLIC
|
Modifier.TRANSIENT
| Modifier.FINAL
matches all final transient methods that are either public or protected.readSuperclass
- methods from all subclasses (up to readSuperclass
) are also returned, otherwise, only
methods declared in the readClass
are checkedprotected java.lang.reflect.Method getMethod(java.lang.Class<?> key, boolean trySuperClasses)
key
- the differentiating class from method prototypetrySuperClasses
- check all superclasses of the key if a direct match was not foundprotected java.lang.reflect.Method getMethod(java.lang.Object[] arguments) throws java.lang.NoSuchMethodException
getMethod
in class MethodExecutor
arguments
- the arguments of the execution method we are looking forjava.lang.NoSuchMethodException
- if there was no method for the specified argumentspublic <E> java.util.List<java.lang.Class<? extends E>> getDifferentiatingClasses(java.lang.Class<? extends E> subclassesToSearch, int modifiers)
E
- the super-class of the returned classessubclassesToSearch
- a filter the list to contain only the subclasses of this parametermodifiers
- or'ed together (see Modifier
for their list). All set modifiers must be present
for a specific method except for the access modifiers. For example, value
Modifier.PROTECTED
| Modifier.PUBLIC
|
Modifier.TRANSIENT
| Modifier.FINAL
matches all final transient methods that are either public or protected.public <E> java.util.List<java.lang.Class<? extends E>> getDifferentiatingClasses(java.lang.Class<? extends E> subclassesToSearch)
E
- the super-class of the returned classessubclassesToSearch
- a filter the list to contain only the subclasses of this parameterprotected java.util.Collection<java.lang.reflect.Method> getRegisteredMethods()
getRegisteredMethods
in class MethodExecutor