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 Details

    • thenApply

      <U> CompletionStage<U> thenApply(Function<? super T,? extends U> fn)
      Type Parameters:
      U - the mapped type
      Parameters:
      fn - maps the value
      Returns:
      a stage holding the mapped value
    • thenAccept

      CompletionStage<Void> thenAccept(Consumer<? super T> action)
      Parameters:
      action - takes the value
      Returns:
      a stage that completes once the action has run
    • thenRun

      CompletionStage<Void> thenRun(Runnable action)
      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 type
      V - the combined type
      Parameters:
      other - the second stage
      fn - combines both values
      Returns:
      a stage holding the combined value
    • thenCompose

      <U> CompletionStage<U> thenCompose(Function<? super T,? extends CompletionStage<U>> fn)
      Type Parameters:
      U - the adopted type
      Parameters:
      fn - returns the stage whose result this one adopts
      Returns:
      a stage holding that result
    • exceptionally

      CompletionStage<T> exceptionally(Function<Throwable,? extends T> fn)
      Parameters:
      fn - turns a failure into a value
      Returns:
      a stage holding the value or the recovered one
    • handle

      <U> CompletionStage<U> handle(BiFunction<? super T,Throwable,? extends U> fn)
      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

      CompletionStage<T> whenComplete(BiConsumer<? super T,? super Throwable> action)
      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 a CompletableFuture.
      Returns:
      this stage as a CompletableFuture