2 * Copyright (c) 2013 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.builder.impl;
12 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
14 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
17 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
18 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
20 import com.google.common.base.Preconditions;
22 public class ImmutableAugmentationNodeBuilder
23 extends AbstractImmutableDataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> {
25 public static DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> create() {
26 return new ImmutableAugmentationNodeBuilder();
30 public DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> withChild(
31 final DataContainerChild<?, ?> child) {
32 // Check nested augments
33 Preconditions.checkArgument(child instanceof AugmentationNode == false,
34 "Unable to add: %s, as a child for: %s, Nested augmentations are not permitted", child.getNodeType(),
35 getNodeIdentifier() == null ? this : getNodeIdentifier());
37 return super.withChild(child);
41 public DataContainerNodeBuilder<AugmentationIdentifier, AugmentationNode> withoutChild(final PathArgument key) {
42 return super.withoutChild(key);
46 public AugmentationNode build() {
47 return new ImmutableAugmentationNode(getNodeIdentifier(), buildValue());
50 private static final class ImmutableAugmentationNode
51 extends AbstractImmutableDataContainerNode<InstanceIdentifier.AugmentationIdentifier>
52 implements AugmentationNode {
54 ImmutableAugmentationNode(final InstanceIdentifier.AugmentationIdentifier nodeIdentifier, final Map<InstanceIdentifier.PathArgument, DataContainerChild<? extends InstanceIdentifier.PathArgument, ?>> children) {
55 super(children, nodeIdentifier);