NodeItem::findChild: improved Optional idiom
This commit is contained in:
parent
753b37cc1d
commit
77a7946e9c
1 changed files with 3 additions and 6 deletions
|
@ -214,12 +214,9 @@ class NodeItem<T> implements Node<T> {
|
||||||
@Override
|
@Override
|
||||||
public Optional<Node<T>> findChild(@NonNull final T child) {
|
public Optional<Node<T>> findChild(@NonNull final T child) {
|
||||||
return children.stream()
|
return children.stream()
|
||||||
.filter(node -> {
|
.filter(node -> child.equals(node.getData()
|
||||||
final Optional<T> d = node.getData();
|
.orElseGet(() -> null)))
|
||||||
return d.isPresent() && d.get()
|
.findFirst();
|
||||||
.equals(child);
|
|
||||||
})
|
|
||||||
.findAny();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue