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 newAbstractTask
with priority0
.AbstractTask
(Object[] args, int priority) Creates a newAbstractTask
. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
Executes this task with the given arguments.int
Returns the priority of this task.void
run()
Runs thisAbstractTask
.
-
Constructor Details
-
AbstractTask
Creates a newAbstractTask
with 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:
run
in interfaceRunnable
- Specified by:
run
in interfaceTask
- Throws:
ExecutionFailedException
- If an error occurs during execution of the task.ExecutionFailedException
s thrown by the task handler will be propagated unchanged
-
getPriority
public int getPriority()Description copied from interface:Task
Returns the priority of this task. A lower priority number means this task has a higher priority.- Specified by:
getPriority
in interfaceTask
- Returns:
- The priority of this task
-