From f9aba88d0cf97c9dd448d9cb273f746fef2d53c6 Mon Sep 17 00:00:00 2001 From: Paul Campbell Date: Tue, 20 Sep 2016 22:18:00 +0100 Subject: [PATCH] NodeItem::getChild: simplify method --- src/main/java/net/kemitix/node/NodeItem.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/net/kemitix/node/NodeItem.java b/src/main/java/net/kemitix/node/NodeItem.java index b4a6eeb..ea26858 100644 --- a/src/main/java/net/kemitix/node/NodeItem.java +++ b/src/main/java/net/kemitix/node/NodeItem.java @@ -224,11 +224,7 @@ class NodeItem implements Node { @Override public Node getChild(final T child) { - Optional> optional = findChild(child); - if (optional.isPresent()) { - return optional.get(); - } - throw new NodeException("Child not found"); + return findChild(child).orElseThrow(() -> new NodeException("Child not found")); } /**