/*-
 *  Copyright 2020 Beuth Hochschule für Technik Berlin, Hochschule für Technik Stuttgart
 * 
 *  This file is part of CityDoctor2.
 *
 *  CityDoctor2 is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  CityDoctor2 is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with CityDoctor2.  If not, see <https://www.gnu.org/licenses/>.
 */
package de.hft.stuttgart.citydoctor2.check;

import java.io.Serializable;

/**
 * Container class for results of a check. It contains a status, the check which
 * produced the result and optional an error object if there was one.
 * 
 * @author Matthias Betz
 *
 */
public class CheckResult implements Serializable {

	private static final long serialVersionUID = -8775678793477525693L;
	
	private final CheckId id;
	private final ResultStatus status;
	private final CheckError err;

	/**
	 * Constructor for this container
	 * 
	 * @param c   the check which produced this result
	 * @param s   the status of the result
	 * @param err an optional error object
	 */
	public CheckResult(CheckId id, ResultStatus s, CheckError err) {
		this.id = id;
		this.status = s;
		this.err = err;
	}

	public CheckResult(Check check, ResultStatus s, CheckError err) {
		this(check.getCheckId(), s, err);
	}

	public CheckId getCheckIdentifier() {
		return id;
	}

	public ResultStatus getResultStatus() {
		return status;
	}

	public CheckError getError() {
		return err;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("CheckResult [id=");
		builder.append(id);
		builder.append(", status=");
		builder.append(status);
		builder.append(", error=");
		builder.append(err);
		builder.append("]");
		return builder.toString();
	}

}
