package meerkat.pollingstation.controller.callbacks;

import com.google.common.util.concurrent.FutureCallback;
import meerkat.protobuf.PollingStation;

/**
 * Created by Laura on 3/20/2017.
 */
public class ScanDataCallback implements ScanCallback, FutureCallback<PollingStation.ScannedData> {

    private final PollingStation.ScannedData expectedData;
    private boolean dataIsAsExpected;
    private Throwable thrown;

    public ScanDataCallback(PollingStation.ScannedData expectedData) {
        this.expectedData = expectedData;
    }

    public PollingStation.ScannedData getScannedData() {
        return this.expectedData;
    }

    @Override
    public void onSuccess(PollingStation.ScannedData result) {

        dataIsAsExpected = result.getBallot().getChannel().equals(expectedData.getBallot().getChannel());
    }

    @Override
    public void onFailure(Throwable t) {
        dataIsAsExpected = false;
        thrown = t;
    }

    public void doNothing() {
        System.out.println("do nothing hit");
    }
}
