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

li.strolch.search.ValueSearch Maven / Gradle / Ivy

The newest version!
package li.strolch.search;

import java.util.Collection;
import java.util.stream.Stream;

public class ValueSearch implements SearchPredicates {

	private ValueSearchExpression expression;

	public ValueSearch where(ValueSearchExpression expression) {
		if (this.expression == null)
			this.expression = expression;
		else
			this.expression = this.expression.and(expression);
		return this;
	}

	/**
	 * Performs the actual search on the given input list
	 *
	 * @return the search result
	 */
	public SearchResult search(Collection input) {
		return search(input.stream());
	}

	/**
	 * Performs the actual search on the given input list
	 *
	 * @return the search result
	 */
	public SearchResult search(Stream stream) {
		if (this.expression != null)
			stream = stream.filter(e -> this.expression.matches(e));

		return new SearchResult<>(stream);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy