Interface Promise<C>

    • Method Summary

      All Methods Static Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void failed​(java.lang.Throwable x)
      Callback invoked when the operation fails.
      static <T> Promise<T> from​(java.util.concurrent.CompletableFuture<? super T> completable)
      Creates a promise from the given incomplete CompletableFuture.
      static <T> Promise<T> from​(java.util.function.Consumer<T> success, java.util.function.Consumer<java.lang.Throwable> failure)
      Creates a Promise from the given success and failure consumers.
      default void succeeded​(C result)
      Callback invoked when the operation completes.
    • Method Detail

      • succeeded

        default void succeeded​(C result)

        Callback invoked when the operation completes.

        Parameters:
        result - the context
        See Also:
        failed(Throwable)
      • failed

        default void failed​(java.lang.Throwable x)

        Callback invoked when the operation fails.

        Parameters:
        x - the reason for the operation failure
      • from

        static <T> Promise<T> from​(java.util.function.Consumer<T> success,
                                   java.util.function.Consumer<java.lang.Throwable> failure)

        Creates a Promise from the given success and failure consumers.

        Type Parameters:
        T - the type of the result
        Parameters:
        success - the consumer invoked when the promise is succeeded
        failure - the consumer invoked when the promise is failed
        Returns:
        a new Promise wrapping the success and failure consumers.
      • from

        static <T> Promise<T> from​(java.util.concurrent.CompletableFuture<? super T> completable)

        Creates a promise from the given incomplete CompletableFuture.

        When the promise completes, either succeeding or failing, the CompletableFuture is also completed, respectively via CompletableFuture.complete(Object) or CompletableFuture.completeExceptionally(Throwable).

        Type Parameters:
        T - the type of the result
        Parameters:
        completable - the CompletableFuture to convert into a promise
        Returns:
        a promise that when completed, completes the given CompletableFuture