package meerkat.mixer.necessary;


import meerkat.protobuf.BulletinBoardApi.*;
import meerkat.protobuf.Crypto.*;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Arbel Deutsch Peled on 14-Dec-15.
 *
 * A data structure for holding a complete batch message along with its signature
 *
 * ToDo: this should be replaced by CompleteBatch at BB project
 */
public class CompleteBatch {

    private BeginBatchMessage beginBatchMessage;
    private List<BatchChunk> batchChunkList;
    private Signature signature;

    public CompleteBatch() {
        batchChunkList = new LinkedList<BatchChunk>();
    }

    public CompleteBatch(BeginBatchMessage newBeginBatchMessage) {
        this();
        beginBatchMessage = newBeginBatchMessage;
    }

    public CompleteBatch(BeginBatchMessage newBeginBatchMessage, List<BatchChunk> newChunkList) {
        this(newBeginBatchMessage);
        appendBatchChunk(newChunkList);
    }

    public CompleteBatch(BeginBatchMessage newBeginBatchMessage, List<BatchChunk> newChunkList, Signature newSignature) {
        this(newBeginBatchMessage, newChunkList);
        signature = newSignature;
    }

    public BeginBatchMessage getBeginBatchMessage() {
        return beginBatchMessage;
    }

    public List<BatchChunk> getBatchChunkList() {
        return batchChunkList;
    }

    public Signature getSignature() {
        return signature;
    }

    public void setBeginBatchMessage(BeginBatchMessage beginBatchMessage) {
        this.beginBatchMessage = beginBatchMessage;
    }

    public void appendBatchChunk(BatchChunk newBatchChunk) {
        batchChunkList.add(newBatchChunk);
    }

    public void appendBatchChunk(List<BatchChunk> newBatchChunkList) {
        batchChunkList.addAll(newBatchChunkList);
    }

    public void setSignature(Signature newSignature) {
        signature = newSignature;
    }

}
