Package org.incendo.cloud.util
Class CompletableFutures
java.lang.Object
org.incendo.cloud.util.CompletableFutures
CompletableFuture extensions.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> @NonNull CompletableFuture<T> failedFuture(@NonNull Throwable throwable) Returns a failed future that has been exceptionally completed with the giventhrowable.static <T> CompletableFuture<T> scheduleOn(Executor executor, Supplier<CompletableFuture<T>> futureSupplier) Creates a future that schedules a future on the provided executor.
-
Method Details
-
failedFuture
Returns a failed future that has been exceptionally completed with the giventhrowable.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- executorfutureSupplier- future factory- Returns:
- future
-