From 1b0b0222815a284703f1e1a79e77f35b1992f7c4 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Sun, 21 Aug 2016 12:36:40 +0100 Subject: [PATCH] NodeItem.findChild(): rewrite stream filter --- src/main/java/net/kemitix/node/NodeItem.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/kemitix/node/NodeItem.java b/src/main/java/net/kemitix/node/NodeItem.java index 3afbe8b..9e34a83 100644 --- a/src/main/java/net/kemitix/node/NodeItem.java +++ b/src/main/java/net/kemitix/node/NodeItem.java @@ -255,10 +255,10 @@ public class NodeItem implements Node { if (child == null) { throw new NullPointerException("child"); } - return children.stream() - .filter(n -> !n.isEmpty()) - .filter(n -> n.getData().get().equals(child)) - .findAny(); + return children.stream().filter(node -> { + final Optional d = node.getData(); + return d.isPresent() && d.get().equals(child); + }).findAny(); } @Override