Do not use YangInstanceIdentifier#getPath() 75/12975/1
authorRobert Varga <rovarga@cisco.com>
Wed, 19 Nov 2014 21:02:56 +0000 (22:02 +0100)
committerRobert Varga <rovarga@cisco.com>
Thu, 20 Nov 2014 09:55:57 +0000 (10:55 +0100)
Moves TreeNodeUtils away from using deprecated getPath().

Change-Id: Ida7edbd89b08d7365d30d20a1e9657a106886c10
Signed-off-by: Robert Varga <rovarga@cisco.com>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/TreeNodeUtils.java

index f51c0c63fdecc65c56a42634adbb6a079b25988b..491594d1c4649c7370f74b5be036fb1bb60a14e6 100644 (file)
@@ -12,11 +12,9 @@ import com.google.common.base.Preconditions;
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
 import com.google.common.collect.Iterables;
-
 import java.util.AbstractMap.SimpleEntry;
 import java.util.Iterator;
 import java.util.Map;
-
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.StoreTreeNode;
@@ -85,7 +83,7 @@ public final class TreeNodeUtils {
             nesting++;
         }
         if(current.isPresent()) {
-            final YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(path.getPath().subList(0, nesting));
+            final YangInstanceIdentifier currentPath = YangInstanceIdentifier.create(Iterables.limit(path.getPathArguments(), nesting));
             return new SimpleEntry<YangInstanceIdentifier,T>(currentPath,current.get());
         }
 
@@ -96,8 +94,7 @@ public final class TreeNodeUtils {
          * present. At any rate we check state just to be on the safe side.
          */
         Preconditions.checkState(nesting > 0);
-        final YangInstanceIdentifier parentPath = YangInstanceIdentifier.create(path.getPath().subList(0, nesting - 1));
-
+        final YangInstanceIdentifier parentPath = YangInstanceIdentifier.create(Iterables.limit(path.getPathArguments(), nesting - 1));
         return new SimpleEntry<YangInstanceIdentifier,T>(parentPath,parent.get());
     }