Remove an orElse(null) indirection 95/93895/1
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 18 Nov 2020 12:46:36 +0000 (13:46 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 20 Nov 2020 16:56:35 +0000 (17:56 +0100)
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>
(cherry picked from commit 8c0f44e010826c36a232df28385dc591c7f878fd)

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);
             }
         }