BUG-4295: instantiate MERGE operations lazily
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / AugmentationModificationStrategy.java
index 454254ef12d86ad473259f24d3c0642f835dc18f..91fd2e557c62198b728f7fce7a421300a3356c43 100644 (file)
@@ -8,10 +8,12 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import static com.google.common.base.Preconditions.checkArgument;
+
 import java.util.HashSet;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
@@ -20,8 +22,8 @@ import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
 
 final class AugmentationModificationStrategy extends AbstractDataNodeContainerModificationStrategy<AugmentationSchema> {
-    AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) {
-        super(createAugmentProxy(schema,resolved), AugmentationNode.class);
+    AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved, final TreeType treeType) {
+        super(createAugmentProxy(schema,resolved), AugmentationNode.class, treeType);
     }
 
     @Override
@@ -31,9 +33,16 @@ final class AugmentationModificationStrategy extends AbstractDataNodeContainerMo
         return ImmutableAugmentationNodeBuilder.create((AugmentationNode) original);
     }
 
+    @Override
+    protected NormalizedNode<?, ?> createEmptyValue(NormalizedNode<?, ?> original) {
+        checkArgument(original instanceof AugmentationNode);
+        return ImmutableAugmentationNodeBuilder.create()
+                .withNodeIdentifier(((AugmentationNode) original).getIdentifier()).build();
+    }
+
     private static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) {
-        Set<DataSchemaNode> realChildSchemas = new HashSet<>();
-        for(DataSchemaNode augChild : schema.getChildNodes()) {
+        final Set<DataSchemaNode> realChildSchemas = new HashSet<>();
+        for(final DataSchemaNode augChild : schema.getChildNodes()) {
             realChildSchemas.add(resolved.getDataChildByName(augChild.getQName()));
         }
         return new EffectiveAugmentationSchema(schema, realChildSchemas);