Fix yang-data-tree-ri dependencies
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / MandatoryDescendant.java
index 14d2671e45af58b95232d4a2c406b126af721f6b..1bba513a72755d2de0035db12c2f9cc89f603123 100644 (file)
@@ -10,16 +10,13 @@ package org.opendaylight.yangtools.yang.data.tree.impl;
 import static com.google.common.base.Verify.verify;
 import static java.util.Objects.requireNonNull;
 
-import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
@@ -46,25 +43,9 @@ final class MandatoryDescendant implements Immutable {
     }
 
     static @NonNull MandatoryDescendant create(final YangInstanceIdentifier parentId,
-            final DataNodeContainer parentSchema, final DataSchemaNode childSchema, final boolean inAugmentedSubtree) {
-        final NodeIdentifier childId = NodeIdentifier.create(childSchema.getQName());
-
-        if (childSchema.isAugmenting()) {
-            if (!inAugmentedSubtree) {
-                final AugmentationSchemaNode aug = getAugIdentifierOfChild(parentSchema, childSchema);
-                return new MandatoryDescendant(
-                    parentId.node(DataSchemaContextNode.augmentationIdentifierFrom(aug)).node(childId).toOptimized(),
-                    parentId.node(childId).toOptimized());
-            }
-
-            final List<PathArgument> augSubtreePath = parentId.getPathArguments();
-            // in case of augmented choice-case the pathArguments might be empty
-            final YangInstanceIdentifier legacyPath = !augSubtreePath.isEmpty()
-                ? YangInstanceIdentifier.create(augSubtreePath.subList(1, augSubtreePath.size())) : null;
-            return new MandatoryDescendant(parentId.node(childId).toOptimized(), legacyPath);
-        }
-
-        return new MandatoryDescendant(parentId.node(childId).toOptimized(), null);
+            final DataNodeContainer parentSchema, final DataSchemaNode childSchema) {
+        return new MandatoryDescendant(parentId.node(NodeIdentifier.create(childSchema.getQName())).toOptimized(),
+            null);
     }
 
     void enforceOnData(final NormalizedNode data) {
@@ -73,17 +54,15 @@ final class MandatoryDescendant implements Immutable {
             return;
         }
         // ... if we have a legacy path, try that as well ...
-        if (legacyPath != null) {
-            if (NormalizedNodes.findNode(data, legacyPath).isPresent()) {
-                // .. this should not really be happening ...
-                LOG.debug("Found {} at alternate path {}", path, legacyPath);
-                return;
-            }
+        if (legacyPath != null && NormalizedNodes.findNode(data, legacyPath).isPresent()) {
+            // .. this should not really be happening ...
+            LOG.debug("Found {} at alternate path {}", path, legacyPath);
+            return;
         }
 
         // ... not found, report the error
         throw new IllegalArgumentException(String.format("Node %s is missing mandatory descendant %s",
-            data.getIdentifier(), path));
+            data.name(), path));
     }
 
     static AugmentationSchemaNode getAugIdentifierOfChild(final DataNodeContainer parent, final DataSchemaNode child) {