NodeItem.findChild(): rewrite stream filter

This commit is contained in:
Paul Campbell 2016-08-21 12:36:40 +01:00
parent 2da1d9aa3d
commit 1b0b022281

View file

@ -255,10 +255,10 @@ public class NodeItem<T> implements Node<T> {
if (child == null) { if (child == null) {
throw new NullPointerException("child"); throw new NullPointerException("child");
} }
return children.stream() return children.stream().filter(node -> {
.filter(n -> !n.isEmpty()) final Optional<T> d = node.getData();
.filter(n -> n.getData().get().equals(child)) return d.isPresent() && d.get().equals(child);
.findAny(); }).findAny();
} }
@Override @Override