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;
|
return;
|
||||||
}
|
}
|
||||||
String item = path[0];
|
val item = path[0];
|
||||||
final Optional<Node<T>> childNamed = findChildByName(item);
|
findChildByName(item)
|
||||||
Node<T> child;
|
.orElseGet(() -> new NodeItem<>(null, item, this))
|
||||||
if (!childNamed.isPresent()) {
|
.insertInPath(nodeItem, Arrays.copyOfRange(path, 1, path.length));
|
||||||
child = new NodeItem<>(null, item, this);
|
|
||||||
} else {
|
|
||||||
child = childNamed.get();
|
|
||||||
}
|
|
||||||
child.insertInPath(nodeItem, Arrays.copyOfRange(path, 1, path.length));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue