Interface Promise<C>
- Type Parameters:
 C- the type of the promise result
- All Known Subinterfaces:
 Blocker.Promise<C>, Promise.Invocable<R>
- All Known Implementing Classes:
 FuturePromise, Promise.Completable, Promise.Invocable.Abstract, Promise.Invocable.NonBlocking, Promise.Task, Promise.Wrapper
public interface Promise<C>
An abstraction for a completed/failed result of an asynchronous operation.
- 
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classA CompletableFuture that is also a Promise.static interfacestatic classstatic class - 
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidcompleteWith(Promise<T> promise, CompletableFuture<T> completable) Completes the given promise with the givenCompletableFuture.default voidCallback method to invoke when the operation fails.static <T> Promise<T> Creates a promise that runs the givenRunnablewhen it succeeds or fails.static <T> Promise<T> from(CompletableFuture<? super T> completable) Creates a promise from the given incomplete CompletableFuture.static <T> Promise<T> Creates a Promise from the given success and failure consumers.static <T> Promise<T> noop()default voidCallback method to invoke when the operation succeeds. 
- 
Method Details
- 
succeeded
Callback method to invoke when the operation succeeds.
- Parameters:
 result- the operation result- See Also:
 
 - 
failed
Callback method to invoke when the operation fails.
- Parameters:
 x- the operation failure
 - 
noop
- Type Parameters:
 T- the type of the promise result- Returns:
 - a promise that performs no operations.
 
 - 
completeWith
Completes the given promise with the given
CompletableFuture.When the CompletableFuture completes normally, the given promise is succeeded; when the CompletableFuture completes exceptionally, the given promise is failed.
- Parameters:
 promise- the promise to completecompletable- theCompletableFuturethat completes the promise
 - 
from
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 succeededfailure- the consumer invoked when the promise is failed- Returns:
 - a new Promise wrapping the success and failure consumers.
 
 - 
from
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)orCompletableFuture.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
 
 - 
from
 
 -