NodeItem.walkTree(): refactor using existing getChild()

Signed-off-by: Paul Campbell <pcampbell@kemitix.net>
This commit is contained in:
Paul Campbell 2016-01-09 18:09:38 +00:00
parent bff6b5be5e
commit 85bd763e09

View file

@ -110,10 +110,7 @@ public class NodeItem<T> implements Node<T> {
@Override @Override
public Optional<Node<T>> walkTree(@NonNull final List<T> path) { public Optional<Node<T>> walkTree(@NonNull final List<T> path) {
if (path.size() > 0) { if (path.size() > 0) {
Optional<Node<T>> found = children.stream() Optional<Node<T>> found = getChild(path.get(0));
.filter((Node<T> child) -> path.get(0)
.equals(child.getData()))
.findFirst();
if (found.isPresent()) { if (found.isPresent()) {
if (path.size() > 1) { if (path.size() > 1) {
return found.get().walkTree(path.subList(1, path.size())); return found.get().walkTree(path.subList(1, path.size()));