Remove an orElse(null) indirection 79/93879/3
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 18 Nov 2020 12:46:36 +0000 (13:46 +0100)
committerRobert Varga <nite@hq.sk>
Wed, 18 Nov 2020 13:37:44 +0000 (13:37 +0000)
We do not need to update foundNode() if we do not find anything,
hence sync on optional directly. Improves interactions and solves
an Eclipse warning.

Change-Id: Ibc553d50d48ccd22480bdc33163364bc8a509c83
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java

index a0c53dc1fbb631bbb9e58af19871e3708b33a986..ea1a9bf677ff8c0f804180eb2ada9961a6a8df86 100644 (file)
@@ -450,10 +450,10 @@ public final class SchemaContextUtil {
         }
 
         if (foundNode == null && parent instanceof ActionNodeContainer) {
-            foundNode = ((ActionNodeContainer) parent).getActions().stream()
-                    .filter(act -> current.equals(act.getQName())).findFirst().orElse(null);
-            if (foundNode != null && nextPath.iterator().hasNext()) {
-                foundNode = findNodeIn(foundNode, nextPath);
+            final Optional<? extends SchemaNode> next = ((ActionNodeContainer) parent).getActions().stream()
+                .filter(act -> current.equals(act.getQName())).findFirst();
+            if (next.isPresent() && nextPath.iterator().hasNext()) {
+                foundNode = findNodeIn(next.orElseThrow(), nextPath);
             }
         }