in src/main/java/com/spotify/futures/CompletableFutures.java [580:588]
public static <T> CompletionStage<T> combine(
Function<CombinedFutures, T> function, List<? extends CompletionStage<?>> stages) {
@SuppressWarnings("unchecked") // generic array creation
final CompletableFuture<?>[] all = new CompletableFuture[stages.size()];
for (int i = 0; i < stages.size(); i++) {
all[i] = stages.get(i).toCompletableFuture();
}
return CompletableFuture.allOf(all).thenApply(ignored -> function.apply(new CombinedFutures(stages)));
}