li.strolch.search.ValueSearch Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of agent Show documentation
Show all versions of agent Show documentation
Strolch Agent which is the runtime for Strolch
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);
}
}