public class CompletionStageUtils extends Object
CompletionStage
a bit easier to deal with.Constructor and Description |
---|
CompletionStageUtils() |
Modifier and Type | Method and Description |
---|---|
static <T> T |
foldResult(CompletionStage<T> completionStage,
Function<Throwable,T> onError)
Obtain the result of the given
CompletionStage . |
static <T,R> R |
foldResult(CompletionStage<T> completionStage,
Function<T,R> onSuccess,
Function<Throwable,R> onError)
Obtain the result of the given
CompletionStage . |
static void |
joinResult(CompletionStage<?> completionStage,
Consumer<Throwable> onError)
Await the completion of the given
CompletionStage . |
public static <T> T foldResult(CompletionStage<T> completionStage, Function<Throwable,T> onError)
CompletionStage
. If the stage completes with an error, then the given
error handling function will be invoked to transform that error into a result value.public static <T,R> R foldResult(CompletionStage<T> completionStage, Function<T,R> onSuccess, Function<Throwable,R> onError)
CompletionStage
. One of either the success or error handlers will be invoked
depending on the result of the stage.public static void joinResult(CompletionStage<?> completionStage, Consumer<Throwable> onError)
CompletionStage
. If the stage completes with an error, then the given
error handler will be invoked.Copyright © 2003–2017 Atlassian. All rights reserved.