Class AbstractTask

java.lang.Object
org.omegazero.common.event.task.AbstractTask
All Implemented Interfaces:
Comparable<Task>, Runnable, Task
Direct Known Subclasses:
LambdaTask, ReflectTask, RunnableTask

public abstract class AbstractTask extends Object implements Task
A Task with arguments passed to a task handler.
Since:
2.9
API Note:
Before version 2.9, this class was named Task.
  • Constructor Details

    • AbstractTask

      public AbstractTask(Object[] args)
      Creates a new AbstractTask with priority 0.
      Parameters:
      args - The arguments to pass to the task handler when this task is executed
    • AbstractTask

      public AbstractTask(Object[] args, int priority)
      Creates a new AbstractTask.
      Parameters:
      args - The arguments to pass to the task handler when this task is executed
      priority - The priority of this task. Tasks with a lower priority number will be executed first
  • Method Details

    • execute

      protected abstract void execute(Object[] args) throws Exception
      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 this AbstractTask. 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 interface Runnable
      Specified by:
      run in interface Task
      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: Task
      Returns the priority of this task. A lower priority number means this task has a higher priority.
      Specified by:
      getPriority in interface Task
      Returns:
      The priority of this task