NodeItem: simplify inserting child into path
This commit is contained in:
parent
91c57f098e
commit
e28b140db8
1 changed files with 4 additions and 9 deletions
|
@ -301,15 +301,10 @@ class NodeItem<T> implements Node<T> {
|
|||
}
|
||||
return;
|
||||
}
|
||||
String item = path[0];
|
||||
final Optional<Node<T>> childNamed = findChildByName(item);
|
||||
Node<T> child;
|
||||
if (!childNamed.isPresent()) {
|
||||
child = new NodeItem<>(null, item, this);
|
||||
} else {
|
||||
child = childNamed.get();
|
||||
}
|
||||
child.insertInPath(nodeItem, Arrays.copyOfRange(path, 1, path.length));
|
||||
val item = path[0];
|
||||
findChildByName(item)
|
||||
.orElseGet(() -> new NodeItem<>(null, item, this))
|
||||
.insertInPath(nodeItem, Arrays.copyOfRange(path, 1, path.length));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue