com.galenframework.validation.ValidationResult Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of galen-core Show documentation
Show all versions of galen-core Show documentation
A library for layout testing of websites
/*******************************************************************************
* Copyright 2017 Ivan Shubin http://galenframework.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package com.galenframework.validation;
import com.galenframework.specs.Spec;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.util.LinkedList;
import java.util.List;
/**
* Created by ishubin on 2015/02/15.
*/
public class ValidationResult {
private Spec spec;
private List validationObjects = new LinkedList<>();
private ValidationError error;
private List childValidationResults;
public ValidationResult(Spec spec, List validationObjects) {
this.spec = spec;
this.validationObjects = validationObjects;
}
public ValidationResult(Spec spec) {
this.spec = spec;
}
public ValidationResult(Spec spec, List validationObjects, ValidationError validationError) {
this.spec = spec;
this.validationObjects = validationObjects;
this.error = validationError;
}
public List getValidationObjects() {
return validationObjects;
}
public void setValidationObjects(List validationObjects) {
this.validationObjects = validationObjects;
}
public ValidationError getError() {
return error;
}
public void setError(ValidationError error) {
this.error = error;
}
@Override
public int hashCode() {
return new HashCodeBuilder()
.append(validationObjects)
.append(error)
.append(childValidationResults)
.toHashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null)
return false;
if (obj == this)
return true;
if (!(obj instanceof ValidationResult))
return false;
ValidationResult rhs = (ValidationResult)obj;
return new EqualsBuilder()
.append(this.error, rhs.error)
.append(this.validationObjects, rhs.validationObjects)
.append(this.childValidationResults, rhs.childValidationResults)
.isEquals();
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("objects", validationObjects)
.append("error", error)
.append("childValidationResults", childValidationResults)
.toString();
}
public List getChildValidationResults() {
return childValidationResults;
}
public void setChildValidationResults(List childValidationResults) {
this.childValidationResults = childValidationResults;
}
public ValidationResult withObjects(List objects) {
setValidationObjects(objects);
return this;
}
public ValidationResult withError(ValidationError error) {
setError(error);
return this;
}
public ValidationResult withChildValidationResults(List childValidationResults) {
setChildValidationResults(childValidationResults);
return this;
}
public Spec getSpec() {
return spec;
}
}