Class CompletableFutureHelper
java.lang.Object
org.eclipse.microprofile.fault.tolerance.tck.asynchronous.CompletableFutureHelper
- Author:
- Ondrej Mihalyi
-
Method Summary
Modifier and TypeMethodDescriptionstatic <U> CompletableFuture<U>
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.
-
Method Details
-
failedFuture
Creates a future completed with a supplied exception. Equivalent toCompletableFuture
.failedFuture
available since Java 9 but not in Java 8.- Type Parameters:
U
- The type of the future result- Parameters:
ex
- The exception to finish the result with- Returns:
- A future completed with the a supplied exception
ex
-
toCompletableFuture
Returns a future that is completed when the stage is completed and has the same value or exception as the completed stage. It's supposed to be equivalent to callingCompletionStage.toCompletableFuture()
but works with any CompletionStage and doesn't throwUnsupportedOperationException
.- Type Parameters:
U
- The type of the future result- Parameters:
stage
- Stage to convert to a future- Returns:
- Future converted from stage
-