BUG-865: get rid of InstanceIdentifier-related warnings 91/9191/1
authorRobert Varga <rovarga@cisco.com>
Mon, 21 Jul 2014 09:04:12 +0000 (11:04 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 21 Jul 2014 09:06:56 +0000 (11:06 +0200)
InstanceIdentifier has a few deprecated methods, which are still used
all over the place. Migrate their users to new equivalents.

Change-Id: Ifba5dbaee9e3f2a74bc084b085095712f422fb46
Signed-off-by: Robert Varga <rovarga@cisco.com>
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/RuntimeGeneratedMappingServiceImpl.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifier.java
yang/yang-data-api/src/test/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifierTest.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/TreeNodeUtils.java

index e475a6164336e03c2b3f09c6b0eca3117dbe004b..a8e631c46c052cd68a5e63f7dc2b0bd5906c2cfd 100644 (file)
@@ -7,6 +7,13 @@
  */
 package org.opendaylight.yangtools.sal.binding.generator.impl;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+import com.google.common.util.concurrent.ListenableFuture;
+import com.google.common.util.concurrent.SettableFuture;
+
 import java.net.URI;
 import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
@@ -68,15 +75,8 @@ import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-import com.google.common.util.concurrent.ListenableFuture;
-import com.google.common.util.concurrent.SettableFuture;
-
 public class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMappingService, SchemaContextListener,
-        SchemaLock, AutoCloseable, SchemaContextHolder, TypeResolver {
+SchemaLock, AutoCloseable, SchemaContextHolder, TypeResolver {
 
     private static final Logger LOG = LoggerFactory.getLogger(RuntimeGeneratedMappingServiceImpl.class);
 
@@ -219,7 +219,7 @@ public class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMap
 
     private CompositeNode toCompositeNodeImpl(final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier identifier,
             final DataObject object) {
-        PathArgument last = identifier.getPath().get(identifier.getPath().size() - 1);
+        PathArgument last = identifier.getLastPathArgument();
         Class<? extends DataContainer> cls = object.getImplementedInterface();
         waitForSchema(cls);
         DataContainerCodec<DataObject> codec = (DataContainerCodec<DataObject>) registry.getCodecForDataObject(cls);
@@ -231,8 +231,7 @@ public class RuntimeGeneratedMappingServiceImpl implements BindingIndependentMap
 
         // val cls = object.implementedInterface;
         // waitForSchema(cls);
-        org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument last = identifier.getPath().get(
-                identifier.getPath().size() - 1);
+        org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument last = identifier.getLastPathArgument();
         AugmentationCodec codec = registry.getCodecForAugmentation((Class) object.getImplementedInterface());
         CompositeNode ret = codec.serialize(new ValueWithQName<DataObject>(last.getNodeType(), object));
         if (last instanceof NodeIdentifierWithPredicates) {
index ab44ab80970450169d97e7a7434699b3650a7188..b864f8a74c99503ceaf1e3e858883592ebd3c6a5 100644 (file)
@@ -6,6 +6,13 @@
  */
 package org.opendaylight.yangtools.yang.data.api;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
 import java.io.Serializable;
 import java.lang.reflect.Array;
 import java.util.Arrays;
@@ -22,13 +29,6 @@ import org.opendaylight.yangtools.concepts.Path;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
 /**
  * Unique identifier of a partical node instance in the data tree.
  *
@@ -137,6 +137,10 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
         return new InstanceIdentifier(path);
     }
 
+    public static final InstanceIdentifier create(final PathArgument... path) {
+        return create(Arrays.asList(path));
+    }
+
     @Override
     public int hashCode() {
         /*
@@ -268,22 +272,22 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
     }
 
     /**
-    *
-    * Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.
-    *
-    * @param origin Instace Identifier from which path arguments are copied.
-    * @return new builder for InstanceIdentifier with path arguments copied from original instance identifier.
-    */
+     *
+     * Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.
+     *
+     * @param origin Instace Identifier from which path arguments are copied.
+     * @return new builder for InstanceIdentifier with path arguments copied from original instance identifier.
+     */
     static public InstanceIdentifierBuilder builder(final InstanceIdentifier origin) {
         return new BuilderImpl(origin.getPath());
     }
-   /**
-    *
-    * Returns new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
-    *
-    * @param node QName of first {@link NodeIdentifier} path argument.
-    * @return  new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
-    */
+    /**
+     *
+     * Returns new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
+     *
+     * @param node QName of first {@link NodeIdentifier} path argument.
+     * @return  new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
+     */
     public static InstanceIdentifierBuilder builder(final QName node) {
         return builder().node(node);
     }
index 827e4f3aa388df8b9f9e75f6e34d97fb49d09cf1..7f643801761ee06182ff95132d8f257d827416dc 100644 (file)
@@ -8,24 +8,27 @@
 
 package org.opendaylight.yangtools.yang.data.api;
 
-import static org.junit.Assert.*;
-import static org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
 
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.Map.Entry;
 
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
 /**
  * Unit tests for InstanceIdentifier.
  *
@@ -44,14 +47,10 @@ public class InstanceIdentifierTest {
     @Test
     public void testHashCodeEquals() {
 
-        InstanceIdentifier id1 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2)));
-        InstanceIdentifier id2 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2)));
-        InstanceIdentifier id3 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName2), new NodeIdentifier(nodeName1)));
-        InstanceIdentifier id4 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1)));
+        InstanceIdentifier id1 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2));
+        InstanceIdentifier id2 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2));
+        InstanceIdentifier id3 = InstanceIdentifier.create(new NodeIdentifier(nodeName2), new NodeIdentifier(nodeName1));
+        InstanceIdentifier id4 = InstanceIdentifier.create(new NodeIdentifier(nodeName1));
 
         assertEquals( "hashCode", id1.hashCode(), id2.hashCode() );
         assertEquals( "equals", true, id1.equals( id2 ) );
@@ -64,47 +63,50 @@ public class InstanceIdentifierTest {
     @Test
     public void testNode() {
 
-        InstanceIdentifier id = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2)));
+        InstanceIdentifier id = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2));
 
         InstanceIdentifier newID = id.node( nodeName3 );
 
         assertNotNull( "InstanceIdentifier is null", newID );
-        assertEquals( "Path size", 3, newID.getPath().size() );
-        assertEquals( "PathArg 1 node type", nodeName1, newID.getPath().get(0).getNodeType() );
-        assertEquals( "PathArg 2 node type", nodeName2, newID.getPath().get(1).getNodeType() );
-        assertEquals( "PathArg 3 node type", nodeName3, newID.getPath().get(2).getNodeType() );
+        assertEquals( "Path size", 3, Iterables.size(newID.getPathArguments()) );
+
+        Iterator<PathArgument> it = newID.getPathArguments().iterator();
+        assertEquals( "PathArg 1 node type", nodeName1, it.next().getNodeType() );
+        assertEquals( "PathArg 2 node type", nodeName2, it.next().getNodeType() );
+        assertEquals( "PathArg 3 node type", nodeName3, it.next().getNodeType() );
 
         newID = id.node( new NodeIdentifier( nodeName3 ) );
 
         assertNotNull( "InstanceIdentifier is null", newID );
-        assertEquals( "Path size", 3, newID.getPath().size() );
-        assertEquals( "PathArg 1 node type", nodeName1, newID.getPath().get(0).getNodeType() );
-        assertEquals( "PathArg 2 node type", nodeName2, newID.getPath().get(1).getNodeType() );
-        assertEquals( "PathArg 3 node type", nodeName3, newID.getPath().get(2).getNodeType() );
+        assertEquals( "Path size", 3, Iterables.size(newID.getPathArguments()) );
+
+        it = newID.getPathArguments().iterator();
+        assertEquals( "PathArg 1 node type", nodeName1, it.next().getNodeType() );
+        assertEquals( "PathArg 2 node type", nodeName2, it.next().getNodeType() );
+        assertEquals( "PathArg 3 node type", nodeName3, it.next().getNodeType() );
     }
 
     @Test
     public void testRelativeTo() {
 
-        InstanceIdentifier id1 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2),
-                                   new NodeIdentifier(nodeName3), new NodeIdentifier(nodeName4)));
-        InstanceIdentifier id2 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2)));
-        InstanceIdentifier id3 = new InstanceIdentifier(
+        InstanceIdentifier id1 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2),
+                new NodeIdentifier(nodeName3), new NodeIdentifier(nodeName4));
+        InstanceIdentifier id2 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2));
+        InstanceIdentifier id3 = InstanceIdentifier.create(
                 Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2)));
 
         Optional<InstanceIdentifier> relative = id1.relativeTo( id2 );
 
         assertEquals( "isPresent", true, relative.isPresent() );
-        assertEquals( "Path size", 2, relative.get().getPath().size() );
-        assertEquals( "PathArg 1 node type", nodeName3, relative.get().getPath().get(0).getNodeType() );
-        assertEquals( "PathArg 2 node type", nodeName4, relative.get().getPath().get(1).getNodeType() );
+
+        Iterable<PathArgument> p = relative.get().getPathArguments();
+        assertEquals( "Path size", 2, Iterables.size(p) );
+        assertEquals( "PathArg 1 node type", nodeName3, Iterables.get(p, 0).getNodeType() );
+        assertEquals( "PathArg 2 node type", nodeName4, Iterables.get(p, 1).getNodeType() );
 
         relative = id2.relativeTo( id3 );
         assertEquals( "isPresent", true, relative.isPresent() );
-        assertEquals( "Path size", 0, relative.get().getPath().size() );
+        assertEquals( "Path size", 0, Iterables.size(relative.get().getPathArguments()) );
 
         relative = id2.relativeTo( id1 );
         assertEquals( "isPresent", false, relative.isPresent() );
@@ -113,15 +115,11 @@ public class InstanceIdentifierTest {
     @Test
     public void testContains() {
 
-        InstanceIdentifier id1 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2),
-                                   new NodeIdentifier(nodeName3), new NodeIdentifier(nodeName4)));
-        InstanceIdentifier id2 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2)));
-        InstanceIdentifier id3 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2)));
-        InstanceIdentifier id4 = new InstanceIdentifier(
-                Lists.newArrayList(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName3)));
+        InstanceIdentifier id1 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2),
+                new NodeIdentifier(nodeName3), new NodeIdentifier(nodeName4));
+        InstanceIdentifier id2 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2));
+        InstanceIdentifier id3 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName2));
+        InstanceIdentifier id4 = InstanceIdentifier.create(new NodeIdentifier(nodeName1), new NodeIdentifier(nodeName3));
 
         assertEquals( "contains", true, id2.contains( id1 ) );
         assertEquals( "contains", true, id2.contains( id3 ) );
@@ -135,8 +133,8 @@ public class InstanceIdentifierTest {
         InstanceIdentifier newID = InstanceIdentifier.of( nodeName1 );
 
         assertNotNull( "InstanceIdentifier is null", newID );
-        assertEquals( "Path size", 1, newID.getPath().size() );
-        assertEquals( "PathArg 1 node type", nodeName1, newID.getPath().get(0).getNodeType() );
+        assertEquals( "Path size", 1, Iterables.size(newID.getPathArguments()) );
+        assertEquals( "PathArg 1 node type", nodeName1, Iterables.get(newID.getPathArguments(), 0).getNodeType() );
 
         assertNotNull( newID.toString() ); // for code coverage
     }
@@ -150,29 +148,33 @@ public class InstanceIdentifierTest {
                 .nodeWithKey( nodeName3, key2, "bar" ).build();
 
         assertNotNull( "InstanceIdentifier is null", newID );
-        assertEquals( "Path size", 3, newID.getPath().size() );
-        assertEquals( "PathArg 1 node type", nodeName1, newID.getPath().get(0).getNodeType() );
-        verifyNodeIdentifierWithPredicates( "PathArg 2", newID.getPath().get(1), nodeName2, key1, "foo" );
-        verifyNodeIdentifierWithPredicates( "PathArg 3", newID.getPath().get(2), nodeName3, key2, "bar" );
+        assertEquals( "Path size", 3, Iterables.size(newID.getPathArguments()) );
+
+        Iterator<PathArgument> it = newID.getPathArguments().iterator();
+        assertEquals( "PathArg 1 node type", nodeName1, it.next().getNodeType() );
+        verifyNodeIdentifierWithPredicates( "PathArg 2", it.next(), nodeName2, key1, "foo" );
+        verifyNodeIdentifierWithPredicates( "PathArg 3", it.next(), nodeName3, key2, "bar" );
 
         newID = InstanceIdentifier.builder( newID ).node( nodeName4 ).build();
 
         assertNotNull( "InstanceIdentifier is null", newID );
-        assertEquals( "Path size", 4, newID.getPath().size() );
-        assertEquals( "PathArg 1 node type", nodeName1, newID.getPath().get(0).getNodeType() );
-        assertEquals( "PathArg 2 node type", nodeName2, newID.getPath().get(1).getNodeType() );
-        assertEquals( "PathArg 3 node type", nodeName3, newID.getPath().get(2).getNodeType() );
-        assertEquals( "PathArg 4 node type", nodeName4, newID.getPath().get(3).getNodeType() );
+        assertEquals( "Path size", 4, Iterables.size(newID.getPathArguments()) );
+
+        it = newID.getPathArguments().iterator();
+        assertEquals( "PathArg 1 node type", nodeName1, it.next().getNodeType() );
+        assertEquals( "PathArg 2 node type", nodeName2, it.next().getNodeType() );
+        assertEquals( "PathArg 3 node type", nodeName3, it.next().getNodeType() );
+        assertEquals( "PathArg 4 node type", nodeName4, it.next().getNodeType() );
 
         newID = InstanceIdentifier.builder( nodeName1 ).build();
 
         assertNotNull( "InstanceIdentifier is null", newID );
-        assertEquals( "Path size", 1, newID.getPath().size() );
-        assertEquals( "PathArg 1 node type", nodeName1, newID.getPath().get(0).getNodeType() );
+        assertEquals( "Path size", 1, Iterables.size(newID.getPathArguments()) );
+        assertEquals( "PathArg 1 node type", nodeName1, Iterables.get(newID.getPathArguments(), 0).getNodeType() );
     }
 
-    private void verifyNodeIdentifierWithPredicates(String prefix,
-                               PathArgument arg, QName nodeName, QName key, Object value ) {
+    private void verifyNodeIdentifierWithPredicates(final String prefix,
+            final PathArgument arg, final QName nodeName, final QName key, final Object value ) {
 
         assertNotNull( prefix + " is null", arg );
         assertEquals( prefix + " class", NodeIdentifierWithPredicates.class, arg.getClass() );
@@ -196,11 +198,11 @@ public class InstanceIdentifierTest {
         assertEquals( "equals", true, node1.equals( node2 ) );
 
         assertEquals( "equals", false,
-                      node1.equals( new NodeIdentifierWithPredicates( nodeName2, key1, "foo" ) ) );
+                node1.equals( new NodeIdentifierWithPredicates( nodeName2, key1, "foo" ) ) );
         assertEquals( "equals", false,
-                      node1.equals( new NodeIdentifierWithPredicates( nodeName1, key2, "foo" ) ) );
+                node1.equals( new NodeIdentifierWithPredicates( nodeName1, key2, "foo" ) ) );
         assertEquals( "equals", false,
-                      node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, "bar" ) ) );
+                node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, "bar" ) ) );
         assertEquals( "equals", false, node1.equals( new Object() ) );
 
         assertNotNull( node1.toString() ); // for code coverage
@@ -216,8 +218,8 @@ public class InstanceIdentifierTest {
 
         assertEquals( "equals", false, node3.equals( node1 ) );
         assertEquals( "equals", false,
-                      node1.equals( new NodeIdentifierWithPredicates( nodeName1,
-                          ImmutableMap.<QName, Object>builder().put( key1, 10 ).put( key3, 20 ).build() ) ) );
+                node1.equals( new NodeIdentifierWithPredicates( nodeName1,
+                        ImmutableMap.<QName, Object>builder().put( key1, 10 ).put( key3, 20 ).build() ) ) );
 
         node1 = new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1,2} );
         node2 = new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1,2} );
@@ -226,11 +228,11 @@ public class InstanceIdentifierTest {
         assertEquals( "equals", true, node1.equals( node2 ) );
 
         assertEquals( "equals", false,
-                      node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1,3} ) ) );
+                node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1,3} ) ) );
         assertEquals( "equals", false,
-                      node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1} ) ) );
+                node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1} ) ) );
         assertEquals( "equals", false,
-                      node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1,2,3} ) ) );
+                node1.equals( new NodeIdentifierWithPredicates( nodeName1, key1, new byte[]{1,2,3} ) ) );
     }
 
     @Test
@@ -292,9 +294,9 @@ public class InstanceIdentifierTest {
         assertEquals( "equals", true, node1.equals( node2 ) );
 
         assertEquals( "equals", false,
-                      node1.equals( new AugmentationIdentifier( Sets.newHashSet( nodeName1, nodeName3 ) ) ) );
+                node1.equals( new AugmentationIdentifier( Sets.newHashSet( nodeName1, nodeName3 ) ) ) );
         assertEquals( "equals", false,
-                      node1.equals( new AugmentationIdentifier( Sets.newHashSet( nodeName1 ) ) ) );
+                node1.equals( new AugmentationIdentifier( Sets.newHashSet( nodeName1 ) ) ) );
         assertEquals( "equals", false, node1.equals( new Object() ) );
 
         assertNotNull( node1.toString() ); // for code coverage
index 5aaeb34a989f98b92bbe5213acca341d54c3d4ba..fe5f4db0bb9d914ed43ea7edf90b69e9ca3070f6 100644 (file)
@@ -85,7 +85,7 @@ public final class TreeNodeUtils {
             nesting++;
         }
         if(current.isPresent()) {
-            final InstanceIdentifier currentPath = new InstanceIdentifier(path.getPath().subList(0, nesting));
+            final InstanceIdentifier currentPath = InstanceIdentifier.create(path.getPath().subList(0, nesting));
             return new SimpleEntry<InstanceIdentifier,T>(currentPath,current.get());
         }
 
@@ -96,7 +96,7 @@ public final class TreeNodeUtils {
          * present. At any rate we check state just to be on the safe side.
          */
         Preconditions.checkState(nesting > 0);
-        final InstanceIdentifier parentPath = new InstanceIdentifier(path.getPath().subList(0, nesting - 1));
+        final InstanceIdentifier parentPath = InstanceIdentifier.create(path.getPath().subList(0, nesting - 1));
 
         return new SimpleEntry<InstanceIdentifier,T>(parentPath,parent.get());
     }