Package io.awspring.cloud.sqs
Class CompletableFutures
java.lang.Object
io.awspring.cloud.sqs.CompletableFutures
Utility methods for using convenient
CompletableFuture
methods from later JDK versions in Java 8.- Since:
- 3.0
- Author:
- Tomaz Fernandes
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFuture<T>
exceptionallyCompose
(CompletableFuture<T> future, Function<Throwable, ? extends CompletableFuture<T>> composingFunction) Compose the provided future with a function that returns another completable future that is executed exceptionally.static <T> CompletableFuture<T>
Create an exceptionally completedCompletableFuture
.static <T,
U> CompletableFuture<U> handleCompose
(CompletableFuture<T> future, BiFunction<? super T, Throwable, ? extends CompletableFuture<U>> composingFunction) Compose the provided future with a function to handle the result, taking a value, a throwable and providing a completable future as a result.
-
Method Details
-
failedFuture
Create an exceptionally completedCompletableFuture
.- Type Parameters:
T
- the future type.- Parameters:
t
- the throwable.- Returns:
- the completable future instance.
-
exceptionallyCompose
public static <T> CompletableFuture<T> exceptionallyCompose(CompletableFuture<T> future, Function<Throwable, ? extends CompletableFuture<T>> composingFunction) Compose the provided future with a function that returns another completable future that is executed exceptionally.- Type Parameters:
T
- the future type.- Parameters:
future
- the future to compose with.composingFunction
- the function for handling the exception.- Returns:
- the completable future.
-
handleCompose
public static <T,U> CompletableFuture<U> handleCompose(CompletableFuture<T> future, BiFunction<? super T, Throwable, ? extends CompletableFuture<U>> composingFunction) Compose the provided future with a function to handle the result, taking a value, a throwable and providing a completable future as a result.- Type Parameters:
T
- the future type.U
- the result type of the composing function.- Parameters:
future
- the future to compose with.composingFunction
- the composing function.- Returns:
- the completable future.
-