org.holmes.collector.GreedyResultCollector Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of holmes-validation Show documentation
Show all versions of holmes-validation Show documentation
Holmes is a library that provides a simple and fluent API for writing business rules validations on Java projects.
The newest version!
package org.holmes.collector;
import org.holmes.OperationMode;
import org.holmes.ResultCollector;
import org.holmes.ValidationResult;
import org.holmes.exception.RuleViolationException;
import org.holmes.exception.ValidationException;
/**
* A {@link ResultCollector} related to the GREEDY {@link OperationMode}.
*
* @author diegossilveira
*/
public class GreedyResultCollector implements ResultCollector {
public void onRuleViolation(RuleViolationException e, ValidationResult result) throws ValidationException {
result.addViolationDescriptor(e.getViolationDescriptor());
}
public void finish(ValidationResult result) throws ValidationException {
if (result.hasViolations()) {
throw new ValidationException(result.getViolationsDescriptors());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy