Class Task<T,E extends Throwable>

java.lang.Object
it.tidalwave.util.Task<T,E>
Direct Known Subclasses:
SimpleTask

public abstract class Task<T,E extends Throwable> extends Object
A class which encapsulates a task.
Author:
Fabrizio Giudici
Status: experimental API
  • Constructor Details

    • Task

      public Task()
      Creates a new Task.
    • Task

      public Task(@Nonnull String name)
      Creates a new Task with the given name.
      Parameters:
      name - the name
  • Method Details

    • run

      public abstract T run() throws E
      The method that must contain the body of the Task.
      Returns:
      the computed value
      Throws:
      E - in case of error
    • toString

      @Nonnull public String toString()
      Overrides:
      toString in class Object
    • ofRunnable

      @Nonnull public static Task<Void,RuntimeException> ofRunnable(@Nonnull Runnable runnable)
      Creates a Task from a Runnable.
      Parameters:
      runnable - the wrapped object
      Returns:
      the Task
      Since:
      3.2-ALPHA-1 (was previously on Task8
    • ofCallable

      @Nonnull public static <T> Task<T,Exception> ofCallable(@Nonnull Callable<? extends T> callable)
      Creates a Task from a Callable.
      Type Parameters:
      T - the return type of the callable
      Parameters:
      callable - the wrapped object
      Returns:
      the Task
      Since:
      3.2-ALPHA-1 (was previously on Task8
    • ofCallback

      @Nonnull public static Task<Void,Throwable> ofCallback(@Nonnull Callback callback)
      Creates a Task from a Callback.
      Parameters:
      callback - the wrapped object
      Returns:
      the Task
      Since:
      3.2-ALPHA-1 (was previously on Task8