Class CompletableFutures

java.lang.Object
org.incendo.cloud.util.CompletableFutures

@API(status=INTERNAL) public final class CompletableFutures extends Object
CompletableFuture extensions.
  • Method Details

    • failedFuture

      public static <T> @NonNull CompletableFuture<T> failedFuture(@NonNull Throwable throwable)
      Returns a failed future that has been exceptionally completed with the given throwable.

      This is equivalent to CompletableFuture.failedFuture(Throwable) that was introduced in Java 9.

      Type Parameters:
      T - future type
      Parameters:
      throwable - throwable to complete future with
      Returns:
      the future
    • scheduleOn

      public static <T> CompletableFuture<T> scheduleOn(Executor executor, Supplier<CompletableFuture<T>> futureSupplier)
      Creates a future that schedules a future on the provided executor.
      Type Parameters:
      T - future result type
      Parameters:
      executor - executor
      futureSupplier - future factory
      Returns:
      future