Fix list modification with DataTree rooted at MapEntryNode 25/43225/3
authorTomas Cere <tcere@cisco.com>
Fri, 5 Aug 2016 11:02:58 +0000 (13:02 +0200)
committerTomas Cere <tcere@cisco.com>
Fri, 5 Aug 2016 11:42:21 +0000 (13:42 +0200)
If we had a data tree that was rooted at a MapEntryNode the
node modification was incorrectly enforcing a MapEntryNode when
trying to write into the dataTree.

Change-Id: I9dc02a1917f38e8a0d62279843974b9869c48693
Signed-off-by: Tomas Cere <tcere@cisco.com>
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/UnorderedMapModificationStrategy.java

index 22f0a7954d802c1af4ae2d83ffb6e2c48a504f99..4a8e7731fcd616246c550c19cd07ad668dd834bf 100644 (file)
@@ -44,6 +44,12 @@ final class UnorderedMapModificationStrategy extends AbstractNodeContainerModifi
     public Optional<ModificationApplyOperation> getChild(final YangInstanceIdentifier.PathArgument identifier) {
         if (identifier instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {
             return entryStrategy;
+        } else if (entryStrategy.isPresent()) {
+            // In case we already are in a MapEntry node(for example DataTree rooted at MapEntry)
+            // try to retrieve the child that the identifier should be pointing to from our entryStrategy
+            // if we have one. If the entryStrategy cannot find this child we just return the absent
+            // we get from it.
+            return entryStrategy.get().getChild(identifier);
         }
         return Optional.absent();
     }