public class CompletableFutureHelper extends Object
Modifier and Type | Method and Description |
---|---|
static <U> CompletableFuture<U> |
failedFuture(Throwable ex)
Creates a future completed with a supplied exception.
|
static <U> CompletableFuture<U> |
toCompletableFuture(CompletionStage<U> stage)
Returns a future that is completed when the stage is completed and has the same value or exception as the
completed stage.
|
public static <U> CompletableFuture<U> failedFuture(Throwable ex)
CompletableFuture
.failedFuture
available since Java 9 but not in Java 8.U
- The type of the future resultex
- The exception to finish the result withex
public static <U> CompletableFuture<U> toCompletableFuture(CompletionStage<U> stage)
CompletionStage.toCompletableFuture()
but
works with any CompletionStage and doesn't throw UnsupportedOperationException
.U
- The type of the future resultstage
- Stage to convert to a futureCopyright © 2016 – 2022 Eclipse Foundation. All rights reserved.
Use is subject to license terms.