2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
10 import static com.google.common.base.Preconditions.checkArgument;
11 import java.util.HashSet;
13 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
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.AugmentationSchema;
18 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
19 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
20 import org.opendaylight.yangtools.yang.model.util.EffectiveAugmentationSchema;
22 final class AugmentationModificationStrategy extends DataNodeContainerModificationStrategy<AugmentationSchema> {
23 AugmentationModificationStrategy(final AugmentationSchema schema, final DataNodeContainer resolved) {
24 super(createAugmentProxy(schema,resolved), AugmentationNode.class);
28 @SuppressWarnings("rawtypes")
29 protected DataContainerNodeBuilder createBuilder(final NormalizedNode<?, ?> original) {
30 checkArgument(original instanceof AugmentationNode);
31 return ImmutableAugmentationNodeBuilder.create((AugmentationNode) original);
34 private static AugmentationSchema createAugmentProxy(final AugmentationSchema schema, final DataNodeContainer resolved) {
35 Set<DataSchemaNode> realChildSchemas = new HashSet<>();
36 for(DataSchemaNode augChild : schema.getChildNodes()) {
37 realChildSchemas.add(resolved.getDataChildByName(augChild.getQName()));
39 return new EffectiveAugmentationSchema(schema, realChildSchemas);