devutility.internal.util.function.PredicateBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of devutility.internal Show documentation
Show all versions of devutility.internal Show documentation
Some utilities for Java development
package devutility.internal.util.function;
import java.util.function.Predicate;
public class PredicateBuilder {
private boolean hasPredicate = false;
private Predicate predicate;
public PredicateBuilder() {
setPredicate(i -> true);
}
public void and(Predicate expression) {
if (!hasPredicate) {
hasPredicate = true;
predicate = expression;
return;
}
predicate = predicate.and(expression);
}
public void or(Predicate expression) {
if (!hasPredicate) {
hasPredicate = true;
predicate = (expression);
return;
}
predicate = (predicate.or(expression));
}
public Predicate getPredicate() {
return predicate;
}
private void setPredicate(Predicate predicate) {
this.predicate = predicate;
}
public boolean isHasPredicate() {
return hasPredicate;
}
}