Add XMLNamespace
[yangtools.git] / yang / yang-data-util / src / main / java / org / opendaylight / yangtools / yang / data / util / ParserStreamUtils.java
index b9c17416fc7c403dbde167e156eb19a5c807e8e1..453d01dadbeb1c283f4895ee082cffff35e38757 100644 (file)
@@ -8,22 +8,21 @@
 
 package org.opendaylight.yangtools.yang.data.util;
 
-import java.net.URI;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Deque;
 import java.util.List;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.Revision;
-import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
+import org.opendaylight.yangtools.yang.common.XMLNamespace;
+import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
 public final class ParserStreamUtils {
-
     private ParserStreamUtils() {
-        throw new UnsupportedOperationException("Utility class should not be instantiated.");
+        // Hidden on purpose
     }
 
     /**
@@ -35,7 +34,7 @@ public final class ParserStreamUtils {
      *         (where n is number of choices through it was passed)
      */
     public static Deque<DataSchemaNode> findSchemaNodeByNameAndNamespace(final DataSchemaNode dataSchemaNode,
-                                                                   final String childName, final URI namespace) {
+            final String childName, final XMLNamespace namespace) {
         final Deque<DataSchemaNode> result = new ArrayDeque<>();
         final List<ChoiceSchemaNode> childChoices = new ArrayList<>();
         DataSchemaNode potentialChildNode = null;
@@ -45,12 +44,10 @@ public final class ParserStreamUtils {
                     childChoices.add((ChoiceSchemaNode) childNode);
                 } else {
                     final QName childQName = childNode.getQName();
-
-                    if (childQName.getLocalName().equals(childName) && childQName.getNamespace().equals(namespace)) {
-                        if (potentialChildNode == null || Revision.compare(childQName.getRevision(),
-                            potentialChildNode.getQName().getRevision()) > 0) {
-                            potentialChildNode = childNode;
-                        }
+                    if (childQName.getLocalName().equals(childName) && childQName.getNamespace().equals(namespace)
+                            && (potentialChildNode == null || Revision.compare(childQName.getRevision(),
+                                potentialChildNode.getQName().getRevision()) > 0)) {
+                        potentialChildNode = childNode;
                     }
                 }
             }
@@ -62,7 +59,7 @@ public final class ParserStreamUtils {
 
         // try to find data schema node in choice (looking for first match)
         for (final ChoiceSchemaNode choiceNode : childChoices) {
-            for (final ChoiceCaseNode concreteCase : choiceNode.getCases().values()) {
+            for (final CaseSchemaNode concreteCase : choiceNode.getCases()) {
                 final Deque<DataSchemaNode> resultFromRecursion = findSchemaNodeByNameAndNamespace(concreteCase,
                         childName, namespace);
                 if (!resultFromRecursion.isEmpty()) {