Package dev.gmitch215.bytebox.locks
Interface CompletionStage<T>
- Type Parameters:
T- the value type
- All Known Implementing Classes:
CompletableFuture
public interface CompletionStage<T>
java.util.concurrent.CompletionStage, which the class library does not carry. It lists the
methods CompletableFuture implements, and the *Async and *Either forms are
not among them.- Since:
- 1.0.3
-
Method Summary
Modifier and TypeMethodDescriptionexceptionally(Function<Throwable, ? extends T> fn) <U> CompletionStage<U> handle(BiFunction<? super T, Throwable, ? extends U> fn) thenAccept(Consumer<? super T> action) <U> CompletionStage<U> <U,V> CompletionStage <V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) <U> CompletionStage<U> thenCompose(Function<? super T, ? extends CompletionStage<U>> fn) Returns this stage as aCompletableFuture.whenComplete(BiConsumer<? super T, ? super Throwable> action)
-
Method Details
-
thenApply
- Type Parameters:
U- the mapped type- Parameters:
fn- maps the value- Returns:
- a stage holding the mapped value
-
thenAccept
- Parameters:
action- takes the value- Returns:
- a stage that completes once the action has run
-
thenRun
- Parameters:
action- runs once this stage completes normally- Returns:
- a stage that completes once the action has run
-
thenCombine
<U,V> CompletionStage<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn) - Type Parameters:
U- the second value typeV- the combined type- Parameters:
other- the second stagefn- combines both values- Returns:
- a stage holding the combined value
-
thenCompose
- Type Parameters:
U- the adopted type- Parameters:
fn- returns the stage whose result this one adopts- Returns:
- a stage holding that result
-
exceptionally
- Parameters:
fn- turns a failure into a value- Returns:
- a stage holding the value or the recovered one
-
handle
- Type Parameters:
U- the mapped type- Parameters:
fn- maps the value and the failure, one of which is null- Returns:
- a stage holding the mapped value
-
whenComplete
- Parameters:
action- sees the value and the failure, one of which is null- Returns:
- a stage with this one's result
-
toCompletableFuture
CompletableFuture<T> toCompletableFuture()Returns this stage as aCompletableFuture.- Returns:
- this stage as a
CompletableFuture
-