org.solidcoding.validation.api.RuleValidationBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of solidcoding-validation Show documentation
Show all versions of solidcoding-validation Show documentation
A small package that enables validation of (business) rules through a fluent API.
package org.solidcoding.validation.api;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
final class RuleValidationBuilder implements ValidationBuilder {
private final T value;
private final List> ruleDefinitions;
public RuleValidationBuilder(T value) {
this.value = value;
this.ruleDefinitions = new ArrayList<>();
}
@Override
public ContinuingValidator compliesWith(Rule rule) {
ruleDefinitions.add(rule);
return new ContinuingPredicateValidator<>(ruleDefinitions, value);
}
@Override
public ContinuingValidator compliesWith(Collection> rules) {
ruleDefinitions.addAll(rules);
return new ContinuingPredicateValidator<>(ruleDefinitions, value);
}
}