package org.easybatch.core.writer;

import org.easybatch.core.record.Batch;

import java.util.List;

import static java.util.Arrays.asList;

/**
 * Composite writer that delegates record writing to a list of writers.
 *
 * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
 */
public class CompositeRecordWriter implements RecordWriter {

    private List<RecordWriter> writers;

    /**
     * Create a {@link CompositeRecordWriter}.
     *
     * @param writers delegates
     */
    public CompositeRecordWriter(List<RecordWriter> writers) {
        this.writers = writers;
    }

    /**
     * Create a {@link CompositeRecordWriter}.
     *
     * @param writers delegates
     */
    public CompositeRecordWriter(RecordWriter... writers) {
        this.writers = asList(writers);
    }

    @Override
    public void open() throws Exception {
        for (RecordWriter writer : writers) {
            writer.open();
        }
    }

    @Override
    public void writeRecords(Batch batch) throws Exception {
        for (RecordWriter writer : writers) {
            writer.writeRecords(batch);
        }
    }

    @Override
    public void close() throws Exception {
        for (RecordWriter writer : writers) {
            writer.close();
        }
    }
}

@@ -98,48 +98,8 @@
 t;%0A%0A
-import static java.util.Arrays.asList;%0A%0A
 /**%0A
@@ -551,217 +551,8 @@
  %7D%0A%0A
-    /**%0A     * Create a %7B@link CompositeRecordWriter%7D.%0A     *%0A     * @param writers delegates%0A     */%0A    public CompositeRecordWriter(RecordWriter... writers) %7B%0A        this.writers = asList(writers);%0A    %7D%0A%0A
     

remove constructor with varargs