Remove Augmentation{Identifier,Node}
[yangtools.git] / data / yang-data-tree-ri / src / main / java / org / opendaylight / yangtools / yang / data / tree / impl / CaseEnforcer.java
index 614779cc7a737a298dd58d5463bfd6efdd470a8f..3c88b78f67d986662ebdcba7f4135a08f6df9632 100644 (file)
@@ -11,18 +11,13 @@ import static java.util.Objects.requireNonNull;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.collect.Sets;
 import java.util.Map.Entry;
 import java.util.Set;
 import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
 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.tree.api.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.tree.api.TreeType;
-import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
-import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.CaseSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 
@@ -31,9 +26,8 @@ class CaseEnforcer implements Immutable {
         private final MandatoryLeafEnforcer enforcer;
 
         EnforcingMandatory(final ImmutableMap<NodeIdentifier, DataSchemaNode> children,
-                final ImmutableMap<AugmentationIdentifier, AugmentationSchemaNode> augmentations,
                 final MandatoryLeafEnforcer enforcer) {
-            super(children, augmentations);
+            super(children);
             this.enforcer = requireNonNull(enforcer);
         }
 
@@ -44,40 +38,28 @@ class CaseEnforcer implements Immutable {
     }
 
     private final ImmutableMap<NodeIdentifier, DataSchemaNode> children;
-    private final ImmutableMap<AugmentationIdentifier, AugmentationSchemaNode> augmentations;
 
-    CaseEnforcer(final ImmutableMap<NodeIdentifier, DataSchemaNode> children,
-            final ImmutableMap<AugmentationIdentifier, AugmentationSchemaNode> augmentations) {
+    CaseEnforcer(final ImmutableMap<NodeIdentifier, DataSchemaNode> children) {
         this.children = requireNonNull(children);
-        this.augmentations = requireNonNull(augmentations);
     }
 
     static CaseEnforcer forTree(final CaseSchemaNode schema, final DataTreeConfiguration treeConfig) {
         final TreeType type = treeConfig.getTreeType();
         final Builder<NodeIdentifier, DataSchemaNode> childrenBuilder = ImmutableMap.builder();
-        final Builder<AugmentationIdentifier, AugmentationSchemaNode> augmentationsBuilder = ImmutableMap.builder();
         if (SchemaAwareApplyOperation.belongsToTree(type, schema)) {
             for (final DataSchemaNode child : schema.getChildNodes()) {
                 if (SchemaAwareApplyOperation.belongsToTree(type, child)) {
                     childrenBuilder.put(NodeIdentifier.create(child.getQName()), child);
                 }
             }
-            for (final AugmentationSchemaNode augment : schema.getAvailableAugmentations()) {
-                if (augment.getChildNodes().stream()
-                        .anyMatch(child -> SchemaAwareApplyOperation.belongsToTree(type, child))) {
-                    augmentationsBuilder.put(DataSchemaContextNode.augmentationIdentifierFrom(augment), augment);
-                }
-            }
         }
 
         final ImmutableMap<NodeIdentifier, DataSchemaNode> children = childrenBuilder.build();
         if (children.isEmpty()) {
             return null;
         }
-        final ImmutableMap<AugmentationIdentifier, AugmentationSchemaNode> augmentations = augmentationsBuilder.build();
         final var enforcer = MandatoryLeafEnforcer.forContainer(schema, treeConfig);
-        return enforcer != null ? new EnforcingMandatory(children, augmentations, enforcer)
-                : new CaseEnforcer(children, augmentations);
+        return enforcer != null ? new EnforcingMandatory(children, enforcer) : new CaseEnforcer(children);
     }
 
     final Set<Entry<NodeIdentifier, DataSchemaNode>> getChildEntries() {
@@ -88,18 +70,6 @@ class CaseEnforcer implements Immutable {
         return children.keySet();
     }
 
-    final Set<Entry<AugmentationIdentifier, AugmentationSchemaNode>> getAugmentationEntries() {
-        return augmentations.entrySet();
-    }
-
-    final Set<AugmentationIdentifier> getAugmentationIdentifiers() {
-        return augmentations.keySet();
-    }
-
-    final Set<PathArgument> getAllChildIdentifiers() {
-        return Sets.union(children.keySet(), augmentations.keySet());
-    }
-
     void enforceOnTreeNode(final NormalizedNode normalizedNode) {
         // Default is no-op
     }