[New] Allow to set input for strolch search

This commit is contained in:
Robert von Burg 2018-08-20 16:35:10 +02:00
parent 178ad78dea
commit 4ffd92e0a7
1 changed files with 37 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package li.strolch.search;
import java.util.List;
import java.util.stream.Stream;
import li.strolch.exception.StrolchAccessDeniedException;
@ -105,6 +106,42 @@ public abstract class StrolchSearch<T extends StrolchRootElement>
return new RootElementSearchResult<>(stream);
}
/**
* Performs the actual search on the given input list
*
* @return the search result
*/
public RootElementSearchResult<T> search(List<T> input) {
// first prepare
define();
Stream<T> stream = input.stream();
if (this.expression != null)
stream = stream.filter(e -> this.expression.matches(e));
return new RootElementSearchResult<>(stream);
}
/**
* Performs the actual search on the given input stream
*
* @return the search result
*/
public RootElementSearchResult<T> search(Stream<T> input) {
// first prepare
define();
Stream<T> stream = input;
if (this.expression != null)
stream = stream.filter(e -> this.expression.matches(e));
return new RootElementSearchResult<>(stream);
}
/**
* @see li.strolch.privilege.model.Restrictable#getPrivilegeName()
*/