package de.dnb.resolvingdienste.urnimporter.urn.export;

import java.time.Instant;

public class ExportResult {

    private final Instant started = Instant.now();
    private boolean successful = false;
    private int errorCode = 0;
    private String errorMessage;
    private Exception exception;
    private Instant finished;

    public void finishedSuccessfully() {
        successful = true;
        errorCode = 0;
        errorMessage = null;
        exception = null;
        finished = Instant.now();
    }

    public void finishedWithError(int code, String message, Exception e) {
        successful = false;
        errorCode = code;
        errorMessage = message;
        exception = e;
        finished = Instant.now();
    }

    public boolean isSuccessful() {
        return successful;
    }

    public void setSuccessful(boolean successful) {
        this.successful = successful;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMessage() {
        return errorMessage;
    }

    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }

    public Exception getException() {
        return exception;
    }

    public void setException(Exception exception) {
        this.exception = exception;
    }

    public Instant getFinished() {
        return finished;
    }

    public void setFinished(Instant finished) {
        this.finished = finished;
    }

    public Instant getStarted() {
        return started;
    }
}
