Remove duplicate instantiation of EffectiveAugmentationSchema
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / tree / AugmentationModificationStrategy.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11
12 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
13 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
15 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
16 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
17 import org.opendaylight.yangtools.yang.model.api.AugmentationSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
19 import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
20
21 final class AugmentationModificationStrategy
22         extends AbstractDataNodeContainerModificationStrategy<AugmentationSchemaNode> {
23     AugmentationModificationStrategy(final AugmentationSchemaNode schema, final DataNodeContainer resolved,
24             final DataTreeConfiguration treeConfig) {
25         super(EffectiveAugmentationSchema.create(schema, resolved), AugmentationNode.class, treeConfig);
26     }
27
28     @Override
29     @SuppressWarnings("rawtypes")
30     protected DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
31         checkArgument(original instanceof AugmentationNode);
32         return ImmutableAugmentationNodeBuilder.create((AugmentationNode) original);
33     }
34
35     @Override
36     protected NormalizedNode<?, ?> createEmptyValue(final NormalizedNode<?, ?> original) {
37         checkArgument(original instanceof AugmentationNode);
38         return ImmutableAugmentationNodeBuilder.create()
39                 .withNodeIdentifier(((AugmentationNode) original).getIdentifier()).build();
40     }
41 }