Unfortunately, to my knowledge CompletableFuture does not support collections.
You could do something like this to make the code a bit cleaner, but it essentially does the same thing
public CompletableFuture> allOf(List> futuresList) {
CompletableFuture allFuturesResult =
CompletableFuture.allOf(futuresList.toArray(new CompletableFuture[futuresList.size()]));
return allFuturesResult.thenApply(v ->
futuresList.stream().
map(future -> future.join()).
collect(Collectors.toList())
);
}
Found this very informative : http://www.nurkiewicz.com/2013/05/java-8-completablefuture-in-action.html