Interface AFutureBase<Self extends AFutureBase<Self>>

  • Type Parameters:
    Self - The concrete future type (AFuture or ARFuture) for fluent chaining.
    All Superinterfaces:
    ToString
    All Known Subinterfaces:
    AFuture, ARFuture<T>
    All Known Implementing Classes:
    ARFutureWithFlag

    public interface AFutureBase<Self extends AFutureBase<Self>>
    extends ToString
    Base interface defining the common life cycle, status, and chaining methods for all asynchronous operations (AFuture and ARFuture).
    • Method Detail

      • updateStatus

        boolean updateStatus​(java.lang.Object result)
      • onError

        Self onError​(AConsumer<java.lang.Throwable> l)
        Registers a listener to be executed if the future completes with an error.
        Parameters:
        l - The consumer that accepts the Throwable error.
        Returns:
        This future instance for chaining.
      • waitSuccessful

        void waitSuccessful()
      • waitSuccessful

        boolean waitSuccessful​(long timeout)
      • isFinalStatus

        boolean isFinalStatus()
        Checks if the future has reached a final state (Done, Erro).
        Returns:
        true if the status is final.
      • isError

        boolean isError()
        Checks if the final status is an error.
        Returns:
        true if the future completed with an error.
      • error

        Self error​(java.lang.Throwable e)
        Completes the future with the given error.
        Parameters:
        e - The Throwable error.
        Returns:
        This future instance for chaining.
      • getError

        java.lang.Throwable getError()
        Gets the error Throwable if the future is in an error state.
        Returns:
        The error or null.
      • setError

        void setError​(java.lang.Throwable e)
        Sets the error Throwable. Same as error(Throwable).
        Parameters:
        e - The Throwable error.
      • isNotDone

        boolean isNotDone()
        Checks if the future has not reached the Done state.
        Returns:
        true if the future is pending or in an Error state.
      • isDone

        boolean isDone()
        Checks if the future has reached the Done state (completed successfully).
        Returns:
        true if completed successfully.
      • timeoutError

        Self timeoutError​(int seconds,
                          java.lang.String text)
        Sets a timeout duration in seconds, after which the future is automatically marked as an error.
        Parameters:
        seconds - Timeout duration.
        text - Error message text.
        Returns:
        This future instance for chaining.
      • timeout

        Self timeout​(int seconds,
                     ARunnable task)
        Sets a timeout duration in seconds, executing a task if the timeout occurs.
        Parameters:
        seconds - Timeout duration.
        task - The task to run on timeout.
        Returns:
        This future instance for chaining.
      • timeoutMs

        Self timeoutMs​(long ms,
                       ARunnable task)
        Sets a timeout duration in milliseconds, executing a task if the timeout occurs.
        Parameters:
        ms - Timeout duration in milliseconds.
        task - The task to run on timeout.
        Returns:
        This future instance for chaining.
      • timeoutMs

        Self timeoutMs​(long ms,
                       AConsumer<Self> task)
        Sets a timeout duration in milliseconds, executing a consumer with this future if the timeout occurs.
        Parameters:
        ms - Timeout duration in milliseconds.
        task - The consumer to run on timeout.
        Returns:
        This future instance for chaining.
      • addListener

        boolean addListener​(AConsumer<Self> l)
        Adds a listener to the future's completion status.
        Parameters:
        l - The consumer that accepts the future instance upon finalization.
        Returns:
        true if the listener was successfully added (and the future was not yet finalized).
      • to

        Self to​(java.util.concurrent.Executor executor,
                ARunnable t)
        Executes a runnable task on the provided executor upon successful completion.
        Parameters:
        executor - The executor to run the task on.
        t - The runnable task.
        Returns:
        This future instance for chaining.
      • to

        Self to​(ARunnable t)
        Executes a runnable task upon successful completion in the current context.
        Parameters:
        t - The runnable task.
        Returns:
        This future instance for chaining.
      • getNowRaw

        java.lang.Object getNowRaw()
        Gets the raw result object. Intended for internal implementation use.
        Returns:
        The raw result object (which may be NULL or Throwable).
      • tryError

        boolean tryError​(@NotNull
                         @NotNull java.lang.Throwable error)
      • cancel

        default void cancel()