Java 8 has a function CompletableFuture.allOf(CompletableFuture<?>...cfs)
that returns a CompletableFuture
that is completed when all the given futures complete.
However, I almost always am not dealing with an array of CompletableFuture
s, but instead have a List<CompletableFuture>
. Of course, I can use the toArray()
method, but this ends up being a bit of a pain to have to constantly convert back and forth between arrays and lists.
It would be really nice if there were a slick way get a CompletableFuture<List<T>>
in exchange for a List<CompletableFuture<T>>
, instead of constantly having to throw in an intermediary array creation. Does anyone know a way to do this in Java 8?