Interface Task<T>

  • Type Parameters:
    T - The result type

    public interface Task<T>
    Represents an asynchronous task.
    Note: The underlying task may already be started.
    • Method Detail

      • isStarted

        boolean isStarted()
        Whether this task has started.
        Returns:
        True, if this task has already started.
      • onError

        @Nonnull
        Task<T> onError​(@Nonnull
                        Consumer<? super Throwable> callback)
        Provide a callback for exception handling.
        This is an asynchronous operation.

        The error will be logged regardless of your callback, this only exists to handle failures for other purposes.

        Parameters:
        callback - The error callback
        Returns:
        The current Task instance for chaining
        Throws:
        IllegalArgumentException - If null is provided
      • onSuccess

        @Nonnull
        Task<T> onSuccess​(@Nonnull
                          Consumer<? super T> callback)
        Provide a callback for success handling.
        This is an asynchronous operation.
        Parameters:
        callback - The success callback
        Returns:
        The current Task instance for chaining
        Throws:
        IllegalArgumentException - If null is provided