/*
 * Copyright (c) 2014 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;

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.DataTreeConfiguration;
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.AugmentationSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;

final class AugmentationModificationStrategy
        extends AbstractDataNodeContainerModificationStrategy<AugmentationSchemaNode> {
    AugmentationModificationStrategy(final AugmentationSchemaNode schema, final DataNodeContainer resolved,
            final DataTreeConfiguration treeConfig) {
        super(EffectiveAugmentationSchema.create(schema, resolved), AugmentationNode.class, treeConfig);
    }

    @Override
    @SuppressWarnings("rawtypes")
    protected DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
        checkArgument(original instanceof AugmentationNode);
        return ImmutableAugmentationNodeBuilder.create((AugmentationNode) original);
    }

    @Override
    protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) {
        checkArgument(original instanceof AugmentationNode);
        return ImmutableAugmentationNodeBuilder.create()
                .withNodeIdentifier(((AugmentationNode) original).getIdentifier()).build();
    }
}

@@ -432,16 +432,43 @@
 ument;%0A%0A
+import java.util.Optional;%0A
 import o
@@ -528,24 +528,24 @@
 tationNode;%0A
-
 import org.o
@@ -686,16 +686,320 @@
 ration;%0A
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;%0Aimport org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;%0Aimport org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;%0Aimport org.opendaylight.yangtools.yang.data.impl.schema.Builders;%0A
 import o
@@ -1179,32 +1179,104 @@
 ionNodeBuilder;%0A
+import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;%0A
 import org.opend
@@ -1613,16 +1613,63 @@
 Node%3E %7B%0A
+    private final AugmentationNode emptyNode;%0A%0A
     Augm
@@ -1818,24 +1818,24 @@
 eeConfig) %7B%0A
-
         supe
@@ -1927,16 +1927,802 @@
 onfig);%0A
+        emptyNode = Builders.augmentationBuilder()%0A                .withNodeIdentifier(DataSchemaContextNode.augmentationIdentifierFrom(schema))%0A                .build();%0A    %7D%0A%0A    @Override%0A    Optional%3CTreeNode%3E apply(final ModifiedNode modification, final Optional%3CTreeNode%3E storeMeta,%0A            final Version version) %7B%0A        return AutomaticLifecycleMixin.apply(super::apply, emptyNode, modification, storeMeta, version);%0A    %7D%0A%0A    @Override%0A    void checkApplicable(final ModificationPath path, final NodeModification modification,%0A            final Optional%3CTreeNode%3E current, final Version version) throws DataValidationFailedException %7B%0A        AutomaticLifecycleMixin.checkApplicable(super::checkApplicable, emptyNode, path, modification, current,%0A            version);%0A
     %7D%0A%0A 

Make empty augmentations disappear