diff options
Diffstat (limited to 'server/src/main')
-rw-r--r-- | server/src/main/java/com/vaadin/data/provider/TreeDataProvider.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/server/src/main/java/com/vaadin/data/provider/TreeDataProvider.java b/server/src/main/java/com/vaadin/data/provider/TreeDataProvider.java index 5436685e58..6fcd029003 100644 --- a/server/src/main/java/com/vaadin/data/provider/TreeDataProvider.java +++ b/server/src/main/java/com/vaadin/data/provider/TreeDataProvider.java @@ -172,9 +172,20 @@ public class TreeDataProvider<T> private Stream<T> getFilteredStream(Stream<T> stream, Optional<SerializablePredicate<T>> queryFilter) { + final Optional<SerializablePredicate<T>> combinedFilter; if (filter != null) { - stream = stream.filter(filter); + combinedFilter = Optional + .of(queryFilter.map(filter::and).orElse(filter)); + } else { + combinedFilter = queryFilter; } - return queryFilter.map(stream::filter).orElse(stream); + return combinedFilter.map( + f -> stream.filter(element -> flatten(element).anyMatch(f))) + .orElse(stream); + } + + private Stream<T> flatten(T element) { + return Stream.concat(Stream.of(element), getTreeData() + .getChildren(element).stream().flatMap(this::flatten)); } } |