What is the correct way to create an already completed CompletableFuture <Void>
I use full-featured futures in java 8, and I want to write a method that, based on the received parameter, launches several tasks with parallel side effects, and then returns their βcombinedβ future (using CompletableFuture.allOf()
), or does nothing and returns the already completed future.
However, allOf
returns a CompletableFuture<Void>
:
public static CompletableFuture<Void> allOf(CompletableFuture<?>... cfs)
And the only way to create an already completed future that knows, uses completedFuture()
, that expects value:
public static <U> CompletableFuture<U> completedFuture(U value)
Returns a new CompletableFuture that is already completed with the given value.
and is Void
not irreversible, so I need another way to create an already completed future type CompletableFuture<Void>
.
?
+4