package de.braintags.vertx.util.async;

import static java.util.stream.Collectors.toList;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import io.vertx.core.CompositeFuture;
import io.vertx.core.Future;

public class SharedCompositeFuture {

  public static SharedFuture<Void> allVoid(final Future<?>... futures) {
    return allVoid(Arrays.asList(futures));
  }

  public static SharedFuture<Void> allVoid(final Collection<? extends Future<?>> futures) {
    return SharedFuture.wrap(CompositeFuture.all(new ArrayList(futures))).mapEmpty();
  }

  public static <T> SharedFuture<List<T>> all(final List<? extends Future<T>> futures) {
    return SharedFuture
        .wrap(CompositeFuture.all((List) futures).map(v -> futures.stream().map(Future::result).collect(toList())));
  }

  public static SharedFuture<CompositeFuture> join(final List<? extends SharedFuture<?>> futures) {
    return SharedFuture.wrap(CompositeFuture.join((List) futures));
  }

}

@@ -865,31 +865,212 @@
 dFuture%3C
-CompositeFuture
+Void%3E joinVoid(final Collection%3C? extends Future%3C?%3E%3E futures) %7B%0A    return SharedFuture.wrap(CompositeFuture.join(new ArrayList(futures))).mapEmpty();%0A  %7D%0A%0A  public static %3CT%3E SharedFuture%3CList%3CT%3E
 %3E join(f
@@ -1093,22 +1093,16 @@
 nds 
-Shared
 Future%3C
-?
+T
 %3E%3E f
@@ -1126,32 +1126,41 @@
 urn SharedFuture
+%0A        
 .wrap(CompositeF
@@ -1177,26 +1177,91 @@
 ((List) futures)
+.map(v -%3E futures.stream().map(Future::result).collect(toList()))
 );%0A  %7D%0A%0A%7D%0A

refactor conversion