Class details

The CompletableFuture<T> class has one nested class that marks asynchronous tasks:

public static interface CompletableFuture.AsynchronousCompletionTask

The constructor for the CompletableFuture<T> class has to be in sync with the provided constructor signature. It also must not take any arguments. The class has the following methods, which are organized by what they return:

Returns CompletionStage:

  • public CompletableFuture<Void> acceptEither(CompletionStage<? extends T> other, Consumer<? super T> action)
  • public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action)
  • public CompletableFuture<Void> acceptEitherAsync(CompletionStage<? extends T> other, Consumer<? super T> action, Executor executor)
  • public <U> CompletableFuture<U> applyToEither(CompletionStage<? extends T> other, Function<? super T, U> fn)
  • public <U> CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn)
  • public <U> CompletableFuture<U> applyToEitherAsync(CompletionStage<? extends T> other, Function<? super T, U> fn, Executor executor)
  • public static <U> CompletedStage<U> completedStage(U value)
  • public static <U> CompletionStage<U> failedStage(Throwable ex)
  • public <U> CompletableFuture<U> handle(BiFunction<? super T, Throwable, ? extends U> fn)
  • public <U> CompletableFuture<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn)
  • public <U> CompletableFuture<U> handleAsync(BiFunction<? super T, Throwable, ? extends U> fn, Executor executor)
  • public CompletionStage<T> minimalCompletionStage()
  • public CompletableFuture<Void> runAfterBoth(CompletionStage<?> other, Runnable action)
  • public CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action)
  • public CompletableFuture<Void> runAfterBothAsync(CompletionStage<?> other, Runnable action, Executor executor)
  • public CompletableFuture<Void> runAfterEither(CompletionStage<?> other, Runnable action)
  • public CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action)
  • public CompletableFuture<Void> runAfterEitherAsync(CompletionStage<?> other, Runnable action, Executor executor)
  • public CompletableFuture<T> whenComplete(BiConsumer<? super T, ? super Throwable> action)
  • public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action)
  • public CompletableFuture<T> whenCompleteAsync(BiConsumer<? super T, ? super Throwable> action, Executor executor)

These methods return CompletionStage:

  • public CompletableFuture<Void> thenAccept(Consumer<? super T> action)
  • public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action)
  • public CompletableFuture<Void> thenAcceptAsync(Consumer<? super T> action, Executor executor)
  • public <U> CompletableFuture<Void> thenAcceptBoth(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action)
  • public <U> CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action)
  • public <U> CompletableFuture<Void> thenAcceptBothAsync(CompletionStage<? extends U> other, BiConsumer<? super T, ? super U> action, Executor executor)
  • public <U> CompletableFuture<U> thenApply(Function<? super T, ? extends U> fn)
  • public <U> CompletableFuture<U> thenApplyAsync(Function<? super T, ? extends U> fn)
  • public <U> CompletableFuture<U> thenApplyAsync(Function<? super T, ? extends U> fn, Executor executor)
  • public <U, V> CompletableFuture<V> thenCombine(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn)
  • public <U, V> CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn)
  • public <U, V> CompletableFuture<V> thenCombineAsync(CompletionStage<? extends U> other, BiFunction<? super T, ? super U, ? extends V> fn, Executor executor)
  • public <U> CompletableFuture<U> thenCompose(Function<? super T, ? extends CompletionStage<U>> fn)
  • public <U> CompletableFuture<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn)
  • public <U> CompletableFuture<U> thenComposeAsync(Function<? super T, ? extends CompletionStage<U>> fn, Executor executor)
  • public CompletableFuture<Void> thenRun(Runnable action)
  • public CompletableFuture<Void>thenRunAsync(Runnable action)
  • public CompletableFuture<Void>thenRunAsync(Runnable action, Executor executor)

These methods return CompletableFuture:

  • public static CompletableFuture<Void> allOf(CompletableFuture<?>...cfs)
  • public static CompletableFuture<Object> anyOf(CompletableFuture<?>... cfs)
  • public CompletableFuture<T> completeAsync(Supplier<? extends T> supplier, Executor executor)
  • public CompletableFuture<T> completeAsync(Supplier<? extends T> supplier)
  • public static <U> CompletableFuture<U> completedFuture(U value)
  • public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit)
  • public CompletableFuture<T> copy()
  • public CompletableFuture<T> exceptionally(Function<Throwable, ? extends T> fn)
  • public static <U> CompletableFuture<U> failedFuture(Throwable ex)
  • public <U> CompletableFuture<U> newIncompeteFuture()
  • public CompletableFuture<T> orTimeout(long timeout, TimeUnit unit)
  • public static ComletableFuture<Void> runAsync(Runnable runnable)
  • public static CompletableFuture<Void> runAsync(Runnable runnable, Executor executor)
  • public static <U> CompletableFuture<U> supplyAsync(Supplier<U> supplier)
  • public static <U> CompletableFuture<U> supplyAsync(Supplier<U. supplier, Executor executor)
  • public CompletableFuture<T> toCompletableFuture()

These methods return Executor:

  • public Executor defaultExecutor()
  • public static Executor delayedExecutor(long delay, Timeunit unit, Executor executor)
  • public static Executor delayedExecutor(long delay, Timeunit unit)

These methods return boolean:

  • public boolean cancel(boolean mayInterruptIfRunning)
  • public boolean complete(T value)
  • public boolean completeExceptionally(Throwable ex)
  • public boolean isCancelled()
  • public boolean isCompletedExceptionally()
  • public boolean isDone()

No return type:

  • public void obtrudeException(Throwable ex)
  • public void obtrudeValue(T value)

Additional methods:

  • public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
  • public T get() throws InterruptedException, ExecutionException
  • public T getNow(T valueIfAbsent)
  • public int getNumberOfDependents()
  • public T join()
  • public String toString()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset