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
|
||||
public Optional<Node<T>> findChild(@NonNull final T child) {
|
||||
return children.stream()
|
||||
.filter(node -> {
|
||||
final Optional<T> d = node.getData();
|
||||
return d.isPresent() && d.get()
|
||||
.equals(child);
|
||||
})
|
||||
.findAny();
|
||||
.filter(node -> child.equals(node.getData()
|
||||
.orElseGet(() -> null)))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue