Remove NormalizedNodePruner.findSchemaNodeForNodePath() 50/81250/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 28 Mar 2019 10:16:27 +0000 (11:16 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 28 Mar 2019 11:02:28 +0000 (12:02 +0100)
DataSchemaContextTree.findChild() provides equivalent functionality,
so use that instead of brewing our own.

JIRA: CONTROLLER-1887
Change-Id: Ia55ac99ce8fa37daf06ce0e7e1615f1bd0a07123
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/transformer/NormalizedNodePruner.java

index cacef95..64dbc18 100644 (file)
@@ -49,7 +49,7 @@ public class NormalizedNodePruner implements NormalizedNodeStreamWriter {
     private boolean sealed = false;
 
     public NormalizedNodePruner(final YangInstanceIdentifier nodePath, final SchemaContext schemaContext) {
-        nodePathSchemaNode = findSchemaNodeForNodePath(nodePath, schemaContext);
+        nodePathSchemaNode = DataSchemaContextTree.from(schemaContext).findChild(nodePath).orElse(null);
     }
 
     @SuppressWarnings("unchecked")
@@ -255,17 +255,4 @@ public class NormalizedNodePruner implements NormalizedNodeStreamWriter {
         stack.push(wrapper);
         return wrapper;
     }
-
-    private static DataSchemaContextNode<?> findSchemaNodeForNodePath(final YangInstanceIdentifier nodePath,
-            final SchemaContext schemaContext) {
-        DataSchemaContextNode<?> schemaNode = DataSchemaContextTree.from(schemaContext).getRoot();
-        for (PathArgument arg : nodePath.getPathArguments()) {
-            schemaNode = schemaNode.getChild(arg);
-            if (schemaNode == null) {
-                break;
-            }
-        }
-
-        return schemaNode;
-    }
 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.