public class MethodThreadList
extends java.lang.Object
A wait function is available - it is a blocking method, which waits for the end of execution for all stored threads.
Parameters from all the stored methods can be retrieved by get operations.
Modifier and Type | Field and Description |
---|---|
protected MethodExecutor |
methodExecutor
MethodExecutor object that is bound to this
|
protected java.util.List<MethodThread> |
methodFinishedList
List of MethodThreads executed on background and now finished
|
protected java.util.List<MethodThread> |
methodStartedList
List of MethodThreads currently executed on background
|
Constructor and Description |
---|
MethodThreadList(MethodExecutor methodExecutor)
Create a new instance of MethodThreadList.
|
Modifier and Type | Method and Description |
---|---|
MethodThread |
backgroundExecute(java.lang.Object... arguments)
Execute registered method by arguments on background.
|
MethodThread |
backgroundExecute(java.lang.Object[] arguments,
Executable executeBefore,
Executable executeAfter)
Execute registered method by arguments on background.
|
MethodThread |
backgroundExecute(java.lang.Object[] arguments,
java.util.List<Executable> executeBefore,
java.util.List<Executable> executeAfter)
Execute registered method by arguments on background.
|
void |
clearThreadLists()
Clears both the lists - started and finished threads.
|
void |
execute(java.lang.Object... arguments)
Execute registered method by arguments
|
<E> java.util.List<E> |
getAllMethodsArgument(java.lang.Class<E> argClass)
Returns list of selected arguments from each finished method.
|
java.util.List<java.lang.Object> |
getAllMethodsArgument(int position)
Get executed argument on the given position from all finished methods
|
java.util.List<java.lang.Object> |
getAllMethodsReturnValue()
Returns a list of values returned from each finished method.
|
<E> java.util.List<E> |
getAllMethodsReturnValue(java.lang.Class<E> valuesClass)
Returns a list of values returned from each finished method.
|
int |
waitBackgroundExecuteOperation()
Wait for all operations executed on background to finish
|
protected final MethodExecutor methodExecutor
protected final java.util.List<MethodThread> methodStartedList
protected final java.util.List<MethodThread> methodFinishedList
public MethodThreadList(MethodExecutor methodExecutor)
methodExecutor
- public void execute(java.lang.Object... arguments) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
arguments
- The array of arguments for the execution method (must be consistent with the prototype in constructor)java.lang.NoSuchMethodException
- if the specified arguments are invalid or a method for them was not foundjava.lang.reflect.InvocationTargetException
- if there was an exception during the method executionpublic MethodThread backgroundExecute(java.lang.Object[] arguments, Executable executeBefore, Executable executeAfter) throws java.lang.NoSuchMethodException
arguments
- The array of arguments for the execution method (must be consistent with the prototype in constructor)executeBefore
- method to call before registered methodexecuteAfter
- method to call after registered methodjava.lang.NoSuchMethodException
- if there was no valid method for the specified argumentspublic MethodThread backgroundExecute(java.lang.Object[] arguments, java.util.List<Executable> executeBefore, java.util.List<Executable> executeAfter) throws java.lang.NoSuchMethodException
arguments
- The array of arguments for the execution method (must be consistent with the prototype in constructor)executeBefore
- list of methods to call before registered methodexecuteAfter
- list of methods to call after registered methodjava.lang.NoSuchMethodException
- if there was no valid method for the specified argumentspublic MethodThread backgroundExecute(java.lang.Object... arguments) throws java.lang.NoSuchMethodException
arguments
- The array of arguments for the execution method (must be consistent with the prototype in constructor)java.lang.NoSuchMethodException
- if there was no valid method for the specified argumentspublic int waitBackgroundExecuteOperation() throws java.lang.InterruptedException
java.lang.InterruptedException
- if the waiting was interruptedpublic void clearThreadLists()
public <E> java.util.List<E> getAllMethodsArgument(java.lang.Class<E> argClass) throws java.util.NoSuchElementException, java.lang.Exception
E
- the class of the selected argumentargClass
- the class of the selected argumentjava.util.NoSuchElementException
- if a parameter with the argClass class was not foundjava.lang.Exception
- if there was an exception during execution of any of the methodspublic java.util.List<java.lang.Object> getAllMethodsArgument(int position) throws java.util.NoSuchElementException, java.lang.Exception
position
- the argument position to getjava.util.NoSuchElementException
- if a parameter with the argClass class was not foundjava.lang.Exception
- if there was an exception during execution of any of the methodspublic <E> java.util.List<E> getAllMethodsReturnValue(java.lang.Class<E> valuesClass) throws java.lang.ClassCastException, java.lang.Exception
E
- the class of the return typesvaluesClass
- the class of the return typesjava.lang.ClassCastException
- if some of the returned values cannot be cast to valuesClass
java.lang.Exception
- if there was an exception during execution of any of the methodspublic java.util.List<java.lang.Object> getAllMethodsReturnValue() throws java.lang.Exception
java.lang.Exception
- if there was an exception during execution of any of the methods