From d9d19a849e448632cd2cae6d04f499263e05e89d Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Mon, 14 Mar 2016 15:42:07 +0000 Subject: [PATCH] NodeItem.findOrCreateChild(): use Optional.orElseGet() to simplify Signed-off-by: Paul Campbell --- src/main/java/net/kemitix/node/NodeItem.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main/java/net/kemitix/node/NodeItem.java b/src/main/java/net/kemitix/node/NodeItem.java index 5321674..3e4186e 100644 --- a/src/main/java/net/kemitix/node/NodeItem.java +++ b/src/main/java/net/kemitix/node/NodeItem.java @@ -166,12 +166,7 @@ public class NodeItem implements Node { if (child == null) { throw new NullPointerException("child"); } - Optional> found = getChild(child); - if (found.isPresent()) { - return found.get(); - } else { - return createChild(child); - } + return getChild(child).orElseGet(() -> createChild(child)); } /**