NodeItem.findOrCreateChild(): use Optional.orElseGet() to simplify
Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
This commit is contained in:
parent
d60f6ae0bb
commit
d9d19a849e
1 changed files with 1 additions and 6 deletions
|
@ -166,12 +166,7 @@ public class NodeItem<T> implements Node<T> {
|
|||
if (child == null) {
|
||||
throw new NullPointerException("child");
|
||||
}
|
||||
Optional<Node<T>> found = getChild(child);
|
||||
if (found.isPresent()) {
|
||||
return found.get();
|
||||
} else {
|
||||
return createChild(child);
|
||||
}
|
||||
return getChild(child).orElseGet(() -> createChild(child));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue