package org.easybatch.core.record;

import java.util.ArrayList;
import java.util.List;

/**
 * Class representing a batch of records.
 *
 * @author Mahmoud Ben Hassine (mahmoud.benhassine@icloud.com)
 */
public class Batch {

    private List<Record> records;

    public Batch() {
        this(new ArrayList<>());
    }

    public Batch(List<Record> records) {
        this.records = records;
    }

    public List<Record> getRecords() {
        return records;
    }

    public void addRecord(final Record record) {
        records.add(record);
    }

    public void removeRecord(final Record record) {
        records.remove(record);
    }


    public boolean isEmpty() {
        return records.isEmpty();
    }

    public long size() {
        return records.size();
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Batch batch = (Batch) o;

        return records.equals(batch.records);

    }

    @Override
    public int hashCode() {
        return records.hashCode();
    }


}

@@ -57,16 +57,46 @@
 ayList;%0A
+import java.util.Collections;%0A
 import j
@@ -337,32 +337,214 @@
 st%3C%3E());%0A    %7D%0A%0A
+    public Batch(Record... records) %7B%0A        List%3CRecord%3E recordList = new ArrayList%3C%3E();%0A        Collections.addAll(recordList, records);%0A        this.records = recordList;%0A    %7D%0A%0A
     public Batch

add method to create a batch with a vararg of records