NodeItem.findOrCreateChild(): use Optional.orElseGet() to simplify

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
This commit is contained in:
Paul Campbell 2016-03-14 15:42:07 +00:00
parent d60f6ae0bb
commit d9d19a849e

View file

@ -166,12 +166,7 @@ public class NodeItem<T> implements Node<T> {
if (child == null) { if (child == null) {
throw new NullPointerException("child"); throw new NullPointerException("child");
} }
Optional<Node<T>> found = getChild(child); return getChild(child).orElseGet(() -> createChild(child));
if (found.isPresent()) {
return found.get();
} else {
return createChild(child);
}
} }
/** /**