org.solidcoding.validation.api.RuleDefinition 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.function.Predicate;
final class RuleDefinition implements Rule {
private final Predicate predicate;
private final String failMessage;
RuleDefinition(Predicate predicate, String failMessage) {
this.predicate = predicate;
this.failMessage = failMessage;
}
@Override
public String getFailMessage() {
return failMessage;
}
@Override
public boolean test(T value) {
return predicate.test(value);
}
}