Do not use SchemaPath in LeafRefContext
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / leafref / LeafRefUtils.java
index ac9fbe9708507e1167179f2316ab1e954ab52500..235e5c31ff3f59f86c3a9c9ed637c222dca628a6 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.data.tree.leafref;
 
+import com.google.common.collect.ImmutableList;
 import java.util.Deque;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -18,7 +19,6 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
 public final class LeafRefUtils {
     private LeafRefUtils() {
@@ -33,9 +33,8 @@ public final class LeafRefUtils {
      * @param module module
      * @return LeafRefPath object
      */
-    public static LeafRefPath createAbsoluteLeafRefPath(
-            final LeafRefPath leafRefPath, final SchemaPath contextNodeSchemaPath,
-            final Module module) {
+    public static LeafRefPath createAbsoluteLeafRefPath(final LeafRefPath leafRefPath,
+            final ImmutableList<QName> contextNodeSchemaPath, final Module module) {
         if (leafRefPath.isAbsolute()) {
             return leafRefPath;
         }
@@ -56,9 +55,10 @@ public final class LeafRefUtils {
         return LeafRefPath.create(absoluteLeafRefTargetPathList, true);
     }
 
-    private static Deque<QNameWithPredicate> schemaPathToXPathQNames(final SchemaPath nodePath, final Module module) {
+    private static Deque<QNameWithPredicate> schemaPathToXPathQNames(final ImmutableList<QName> nodePath,
+            final Module module) {
         final Deque<QNameWithPredicate> xpath = new LinkedList<>();
-        final Iterator<QName> nodePathIterator = nodePath.getPathFromRoot().iterator();
+        final Iterator<QName> nodePathIterator = nodePath.iterator();
 
         DataNodeContainer currenDataNodeContainer = module;
         while (nodePathIterator.hasNext()) {
@@ -90,7 +90,7 @@ public final class LeafRefUtils {
         return xpath;
     }
 
-    public static LeafRefPath schemaPathToLeafRefPath(final SchemaPath nodePath, final Module module) {
+    public static LeafRefPath schemaPathToLeafRefPath(final ImmutableList<QName> nodePath, final Module module) {
         return LeafRefPath.create(schemaPathToXPathQNames(nodePath, module), true);
     }
 }