All Downloads are FREE. Search and download functionalities are using the official Maven repository.

devutility.internal.util.function.PredicateBuilder Maven / Gradle / Ivy

There is a newer version: 1.3.8.1
Show newest version
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;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy