Package org.omegazero.common.event.task
Class AbstractTask
java.lang.Object
org.omegazero.common.event.task.AbstractTask
- All Implemented Interfaces:
Comparable<Task>,Runnable,Task
- Direct Known Subclasses:
LambdaTask,ReflectTask,RunnableTask
A
Task with arguments passed to a task handler.- Since:
- 2.9
- API Note:
- Before version 2.9, this class was named
Task.
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractTask(Object[] args) Creates a newAbstractTaskwith priority0.AbstractTask(Object[] args, int priority) Creates a newAbstractTask. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidExecutes this task with the given arguments.intReturns the priority of this task.voidrun()Runs thisAbstractTask.
-
Constructor Details
-
AbstractTask
Creates a newAbstractTaskwith priority0.- Parameters:
args- The arguments to pass to the task handler when this task is executed
-
AbstractTask
Creates a newAbstractTask.- Parameters:
args- The arguments to pass to the task handler when this task is executedpriority- The priority of this task. Tasks with a lower priority number will be executed first
-
-
Method Details
-
execute
Executes this task with the given arguments.- Parameters:
args- The arguments to pass to the task handler- Throws:
Exception- If an error occurs
-
run
public void run()Runs thisAbstractTask. Exact behavior is implementation-defined.General behavior includes running a task handler (for example a method) with the arguments passed in the constructor.
- Specified by:
runin interfaceRunnable- Specified by:
runin interfaceTask- Throws:
ExecutionFailedException- If an error occurs during execution of the task.ExecutionFailedExceptions thrown by the task handler will be propagated unchanged
-
getPriority
public int getPriority()Description copied from interface:TaskReturns the priority of this task. A lower priority number means this task has a higher priority.- Specified by:
getPriorityin interfaceTask- Returns:
- The priority of this task
-