Vert.x java List<Futures> parameterization
On one hand, you can't use CompositeFuture.all()
with list of parametrized futures. This is a design decision that the developers took, due to type erasure.
But actually, CompositeFuture.all()
doesn't do anything special. So you may have your own interface with static method, that will do the same:
interface MyCompositeFuture extends CompositeFuture {
// This is what the regular does, just for example
/*
static CompositeFuture all(List<Future> futures) {
return CompositeFutureImpl.all(futures.toArray(new Future[futures.size()]));
}
*/
static <T> CompositeFuture all(List<Future<T>> futures) {
return CompositeFutureImpl.all(futures.toArray(new Future[futures.size()]));
}
}
And now:
List<Future<String>> listFuturesT = new ArrayList<>();
// This works
MyCompositeFuture.all(listFuturesT);
List<Future> listFutures = new ArrayList<>();
// This doesnt, and that's the reason for initial design decision
MyCompositeFuture.all(listFutures);