@Override
public OutputPort batch(final String id, final Object args, final Handler<OutputBatch> handler) {
final List<OutputBatch> batches = new ArrayList<>();
final int streamsSize = streams.size();
if (streamsSize == 0) {
handler.handle(new BaseOutputBatch(id, vertx, batches));
} else {
for (OutputStream stream : streams) {
stream.batch(id, args, new Handler<OutputBatch>() {
@Override
public void handle(OutputBatch batch) {
batches.add(batch);
if (batches.size() == streamsSize) {
handler.handle(new BaseOutputBatch(id, vertx, batches));
}
}
});
}
}