T - a type of the successfully resolved promise valuepublic interface Promise<T> extends Future<T>, CompletionStage<T>
Promise is a combination of the CompletionStage and Future contracts.
It provides both composition methods of the former and blocking access methods of the later.
Every composition method derived from the CompletionStage interface is overridden to
return a new Promise;
| Modifier and Type | Method and Description |
|---|---|
Promise<Void> |
acceptEither(CompletionStage<? extends T> other,
Consumer<? super T> action) |
Promise<Void> |
acceptEitherAsync(CompletionStage<? extends T> other,
Consumer<? super T> action) |
Promise<Void> |
acceptEitherAsync(CompletionStage<? extends T> other,
Consumer<? super T> action,
Executor executor) |
<U> Promise<U> |
applyToEither(CompletionStage<? extends T> other,
Function<? super T,U> fn) |
<U> Promise<U> |
applyToEitherAsync(CompletionStage<? extends T> other,
Function<? super T,U> fn) |
<U> Promise<U> |
applyToEitherAsync(CompletionStage<? extends T> other,
Function<? super T,U> fn,
Executor executor) |
default <D> D |
as(Function<? super Promise<T>,D> decoratorFactory)
Decorate this
Promise with a decorator specified |
default Promise<T> |
defaultAsyncOn(Executor executor) |
default Promise<T> |
delay(Duration duration) |
default Promise<T> |
delay(Duration duration,
boolean delayOnError) |
default Promise<T> |
delay(long timeout,
TimeUnit unit) |
default Promise<T> |
delay(long timeout,
TimeUnit unit,
boolean delayOnError) |
default DependentPromise<T> |
dependent()
Converts this
Promise to a DependentPromise
The returned DependentPromise does not implicitly enlist any CompletionStage
for cancellation (neither self, nor passed as arguments to combining methods);
only enlisting via explicit parameter is supported |
default DependentPromise<T> |
dependent(Set<PromiseOrigin> defaultEnlistOptions)
Converts this
Promise to a DependentPromise
The returned DependentPromise does implicitly enlist CompletionStage
for cancellation (either self, and/or passed as arguments to combining methods)
according to defaultEnlistOptions parameter |
Promise<T> |
exceptionally(Function<Throwable,? extends T> fn) |
default Promise<T> |
exceptionallyAsync(Function<Throwable,? extends T> fn) |
default Promise<T> |
exceptionallyAsync(Function<Throwable,? extends T> fn,
Executor executor) |
default Promise<T> |
exceptionallyCompose(Function<Throwable,? extends CompletionStage<T>> fn) |
default Promise<T> |
exceptionallyComposeAsync(Function<Throwable,? extends CompletionStage<T>> fn) |
default Promise<T> |
exceptionallyComposeAsync(Function<Throwable,? extends CompletionStage<T>> fn,
Executor executor) |
default T |
getNow(Supplier<? extends T> valueIfAbsent) |
default T |
getNow(T valueIfAbsent) |
<U> Promise<U> |
handle(BiFunction<? super T,Throwable,? extends U> fn) |
<U> Promise<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> fn) |
<U> Promise<U> |
handleAsync(BiFunction<? super T,Throwable,? extends U> fn,
Executor executor) |
default boolean |
isCompletedExceptionally() |
default T |
join() |
default Promise<T> |
onCancel(Runnable action) |
default Promise<T> |
onTimeout(Supplier<? extends T> supplier,
Duration duration) |
default Promise<T> |
onTimeout(Supplier<? extends T> supplier,
Duration duration,
boolean cancelOnTimeout) |
default Promise<T> |
onTimeout(Supplier<? extends T> supplier,
long timeout,
TimeUnit unit) |
default Promise<T> |
onTimeout(Supplier<? extends T> supplier,
long timeout,
TimeUnit unit,
boolean cancelOnTimeout) |
default Promise<T> |
onTimeout(T value,
Duration duration) |
default Promise<T> |
onTimeout(T value,
Duration duration,
boolean cancelOnTimeout) |
default Promise<T> |
onTimeout(T value,
long timeout,
TimeUnit unit) |
default Promise<T> |
onTimeout(T value,
long timeout,
TimeUnit unit,
boolean cancelOnTimeout) |
default Promise<T> |
orTimeout(Duration duration) |
default Promise<T> |
orTimeout(Duration duration,
boolean cancelOnTimeout) |
default Promise<T> |
orTimeout(long timeout,
TimeUnit unit) |
default Promise<T> |
orTimeout(long timeout,
TimeUnit unit,
boolean cancelOnTimeout) |
default Promise<T> |
raw()
Fully unwraps underlying
Promise (removes all decoration layers) |
Promise<Void> |
runAfterBoth(CompletionStage<?> other,
Runnable action) |
Promise<Void> |
runAfterBothAsync(CompletionStage<?> other,
Runnable action) |
Promise<Void> |
runAfterBothAsync(CompletionStage<?> other,
Runnable action,
Executor executor) |
Promise<Void> |
runAfterEither(CompletionStage<?> other,
Runnable action) |
Promise<Void> |
runAfterEitherAsync(CompletionStage<?> other,
Runnable action) |
Promise<Void> |
runAfterEitherAsync(CompletionStage<?> other,
Runnable action,
Executor executor) |
Promise<Void> |
thenAccept(Consumer<? super T> action) |
Promise<Void> |
thenAcceptAsync(Consumer<? super T> action) |
Promise<Void> |
thenAcceptAsync(Consumer<? super T> action,
Executor executor) |
<U> Promise<Void> |
thenAcceptBoth(CompletionStage<? extends U> other,
BiConsumer<? super T,? super U> action) |
<U> Promise<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> other,
BiConsumer<? super T,? super U> action) |
<U> Promise<Void> |
thenAcceptBothAsync(CompletionStage<? extends U> other,
BiConsumer<? super T,? super U> action,
Executor executor) |
<U> Promise<U> |
thenApply(Function<? super T,? extends U> fn) |
<U> Promise<U> |
thenApplyAsync(Function<? super T,? extends U> fn) |
<U> Promise<U> |
thenApplyAsync(Function<? super T,? extends U> fn,
Executor executor) |
<U,V> Promise<V> |
thenCombine(CompletionStage<? extends U> other,
BiFunction<? super T,? super U,? extends V> fn) |
<U,V> Promise<V> |
thenCombineAsync(CompletionStage<? extends U> other,
BiFunction<? super T,? super U,? extends V> fn) |
<U,V> Promise<V> |
thenCombineAsync(CompletionStage<? extends U> other,
BiFunction<? super T,? super U,? extends V> fn,
Executor executor) |
<U> Promise<U> |
thenCompose(Function<? super T,? extends CompletionStage<U>> fn) |
<U> Promise<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn) |
<U> Promise<U> |
thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn,
Executor executor) |
default Promise<T> |
thenFilter(Predicate<? super T> predicate) |
default Promise<T> |
thenFilter(Predicate<? super T> predicate,
Function<? super T,Throwable> errorSupplier) |
default Promise<T> |
thenFilterAsync(Predicate<? super T> predicate) |
default Promise<T> |
thenFilterAsync(Predicate<? super T> predicate,
Executor executor) |
default Promise<T> |
thenFilterAsync(Predicate<? super T> predicate,
Function<? super T,Throwable> errorSupplier) |
default Promise<T> |
thenFilterAsync(Predicate<? super T> predicate,
Function<? super T,Throwable> errorSupplier,
Executor executor) |
Promise<Void> |
thenRun(Runnable action) |
Promise<Void> |
thenRunAsync(Runnable action) |
Promise<Void> |
thenRunAsync(Runnable action,
Executor executor) |
default Promise<T> |
unwrap()
Unwraps underlying
Promise if it was decorated (removes one level of decorators) |
Promise<T> |
whenComplete(BiConsumer<? super T,? super Throwable> action) |
Promise<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> action) |
Promise<T> |
whenCompleteAsync(BiConsumer<? super T,? super Throwable> action,
Executor executor) |
toCompletableFuturedefault T getNow(T valueIfAbsent) throws CancellationException, CompletionException
default T getNow(Supplier<? extends T> valueIfAbsent) throws CancellationException, CompletionException
default T join() throws CancellationException, CompletionException
default boolean isCompletedExceptionally()
default Promise<T> onTimeout(T value, long timeout, TimeUnit unit, boolean cancelOnTimeout)
default Promise<T> onTimeout(Supplier<? extends T> supplier, long timeout, TimeUnit unit, boolean cancelOnTimeout)
default Promise<T> onTimeout(Supplier<? extends T> supplier, Duration duration, boolean cancelOnTimeout)
default DependentPromise<T> dependent()
Promise to a DependentPromise
The returned DependentPromise does not implicitly enlist any CompletionStage
for cancellation (neither self, nor passed as arguments to combining methods);
only enlisting via explicit parameter is supporteddefault DependentPromise<T> dependent(Set<PromiseOrigin> defaultEnlistOptions)
Promise to a DependentPromise
The returned DependentPromise does implicitly enlist CompletionStage
for cancellation (either self, and/or passed as arguments to combining methods)
according to defaultEnlistOptions parameterdefaultEnlistOptions - defines what CompletionStage should be enlisted implicitly for cancellationdefault <D> D as(Function<? super Promise<T>,D> decoratorFactory)
Promise with a decorator specifiedD - type of the actual promise decoratordecoratorFactory - a factory to create a concrete decoratordefault Promise<T> unwrap()
Promise if it was decorated (removes one level of decorators)Promise or self if not decorateddefault Promise<T> raw()
Promise (removes all decoration layers)Promise or self if not decorated<U> Promise<U> thenApply(Function<? super T,? extends U> fn)
thenApply in interface CompletionStage<T><U> Promise<U> thenApplyAsync(Function<? super T,? extends U> fn)
thenApplyAsync in interface CompletionStage<T><U> Promise<U> thenApplyAsync(Function<? super T,? extends U> fn, Executor executor)
thenApplyAsync in interface CompletionStage<T>Promise<Void> thenAccept(Consumer<? super T> action)
thenAccept in interface CompletionStage<T>Promise<Void> thenAcceptAsync(Consumer<? super T> action)
thenAcceptAsync in interface CompletionStage<T>Promise<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor)
thenAcceptAsync in interface CompletionStage<T>Promise<Void> thenRun(Runnable action)
thenRun in interface CompletionStage<T>Promise<Void> thenRunAsync(Runnable action)
thenRunAsync in interface CompletionStage<T>Promise<Void> thenRunAsync(Runnable action, Executor executor)
thenRunAsync in interface CompletionStage<T><U,V> Promise<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
thenCombine in interface CompletionStage<T><U,V> Promise<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn)
thenCombineAsync in interface CompletionStage<T><U,V> Promise<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T,? super U,? extends V> fn, Executor executor)
thenCombineAsync in interface CompletionStage<T><U> Promise<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
thenAcceptBoth in interface CompletionStage<T><U> Promise<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action)
thenAcceptBothAsync in interface CompletionStage<T><U> Promise<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T,? super U> action, Executor executor)
thenAcceptBothAsync in interface CompletionStage<T>Promise<Void> runAfterBoth(CompletionStage<?> other, Runnable action)
runAfterBoth in interface CompletionStage<T>Promise<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action)
runAfterBothAsync in interface CompletionStage<T>Promise<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
runAfterBothAsync in interface CompletionStage<T><U> Promise<U> applyToEither(CompletionStage<? extends T> other, Function<? super T,U> fn)
applyToEither in interface CompletionStage<T><U> Promise<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn)
applyToEitherAsync in interface CompletionStage<T><U> Promise<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T,U> fn, Executor executor)
applyToEitherAsync in interface CompletionStage<T>Promise<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
acceptEither in interface CompletionStage<T>Promise<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
acceptEitherAsync in interface CompletionStage<T>Promise<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
acceptEitherAsync in interface CompletionStage<T>Promise<Void> runAfterEither(CompletionStage<?> other, Runnable action)
runAfterEither in interface CompletionStage<T>Promise<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action)
runAfterEitherAsync in interface CompletionStage<T>Promise<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
runAfterEitherAsync in interface CompletionStage<T><U> Promise<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
thenCompose in interface CompletionStage<T><U> Promise<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn)
thenComposeAsync in interface CompletionStage<T><U> Promise<U> thenComposeAsync(Function<? super T,? extends CompletionStage<U>> fn, Executor executor)
thenComposeAsync in interface CompletionStage<T>Promise<T> exceptionally(Function<Throwable,? extends T> fn)
exceptionally in interface CompletionStage<T>default Promise<T> exceptionallyAsync(Function<Throwable,? extends T> fn, Executor executor)
default Promise<T> exceptionallyCompose(Function<Throwable,? extends CompletionStage<T>> fn)
default Promise<T> exceptionallyComposeAsync(Function<Throwable,? extends CompletionStage<T>> fn)
default Promise<T> exceptionallyComposeAsync(Function<Throwable,? extends CompletionStage<T>> fn, Executor executor)
default Promise<T> thenFilter(Predicate<? super T> predicate, Function<? super T,Throwable> errorSupplier)
default Promise<T> thenFilterAsync(Predicate<? super T> predicate, Function<? super T,Throwable> errorSupplier)
default Promise<T> thenFilterAsync(Predicate<? super T> predicate, Executor executor)
default Promise<T> thenFilterAsync(Predicate<? super T> predicate, Function<? super T,Throwable> errorSupplier, Executor executor)
Promise<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
whenComplete in interface CompletionStage<T>Promise<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action)
whenCompleteAsync in interface CompletionStage<T>Promise<T> whenCompleteAsync(BiConsumer<? super T,? super Throwable> action, Executor executor)
whenCompleteAsync in interface CompletionStage<T><U> Promise<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
handle in interface CompletionStage<T><U> Promise<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn)
handleAsync in interface CompletionStage<T><U> Promise<U> handleAsync(BiFunction<? super T,Throwable,? extends U> fn, Executor executor)
handleAsync in interface CompletionStage<T>Copyright © 2021. All rights reserved.