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>
private boolean sealed = false;
public NormalizedNodePruner(final YangInstanceIdentifier nodePath, final SchemaContext schemaContext) {
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")
}
@SuppressWarnings("unchecked")
stack.push(wrapper);
return wrapper;
}
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;
- }