package marketing.heyday.hartmann.fotodocumentation.rest.jackson;

import java.util.HashSet;
import java.util.Set;

import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;

import com.networknt.schema.ValidationMessage;

/**
 * 
 * <p>Copyright: Copyright (c) 2017</p>
 * <p>Company: heyday marketing GmbH</p>
 * @author <a href="mailto:p.verboom@heyday.marketing">Patrick Verboom</a>
 * @version 1.0
 * 
 * created: Feb 14, 2017
 */
public final class ValidationReply {
	public final boolean success;
	public final Set<ValidationMessage> errors = new HashSet<>();

	private ValidationReply(boolean success, Set<ValidationMessage> errors) {
		this.success = success;
		this.errors.addAll(errors);
	}

	public Response getErrorResponse() {
		return Response.status(Status.BAD_REQUEST).entity(errors).build();
	}

	public static final class Builder {
		private boolean success;
		private Set<ValidationMessage> errors = new HashSet<>();

		public Builder success(boolean success) {
			this.success = success;
			return this;
		}

		public Builder errors(Set<ValidationMessage> errors) {
			this.errors = errors;
			return this;
		}

		public ValidationReply build() {
			return new ValidationReply(success, errors);
		}
	}
}
