Class CompletableFutures

java.lang.Object
io.awspring.cloud.sqs.CompletableFutures

public class CompletableFutures extends Object
Utility methods for using convenient CompletableFuture methods from later JDK versions in Java 8.
Since:
3.0
Author:
Tomaz Fernandes
  • Method Details

    • failedFuture

      public static <T> CompletableFuture<T> failedFuture(Throwable t)
      Create an exceptionally completed CompletableFuture.
      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.