BUG-4295: instantiate MERGE operations lazily
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / OrderedMapModificationStrategy.java
index 6febd4e5cecf64577b2d7c324683f09af4d2b333..c69a170f246550b8a2f53ef5899ad47c7cc86ce0 100644 (file)
@@ -1,3 +1,11 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import static com.google.common.base.Preconditions.checkArgument;
@@ -15,7 +23,7 @@ final class OrderedMapModificationStrategy extends AbstractNodeContainerModifica
     private final Optional<ModificationApplyOperation> entryStrategy;
 
     OrderedMapModificationStrategy(final ListSchemaNode schema, final TreeType treeType) {
-        super(OrderedMapNode.class);
+        super(OrderedMapNode.class, treeType);
         entryStrategy = Optional.<ModificationApplyOperation> of(new ListEntryModificationStrategy(schema, treeType));
     }
 
@@ -31,6 +39,13 @@ final class OrderedMapModificationStrategy extends AbstractNodeContainerModifica
         return ImmutableOrderedMapNodeBuilder.create((OrderedMapNode) original);
     }
 
+    @Override
+    protected NormalizedNode<?, ?> createEmptyValue(NormalizedNode<?, ?> original) {
+        checkArgument(original instanceof OrderedMapNode);
+        return ImmutableOrderedMapNodeBuilder.create().withNodeIdentifier(((OrderedMapNode) original).getIdentifier())
+                .build();
+    }
+
     @Override
     public Optional<ModificationApplyOperation> getChild(final YangInstanceIdentifier.PathArgument identifier) {
         if (identifier instanceof YangInstanceIdentifier.NodeIdentifierWithPredicates) {