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.schema.AugmentationNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
15 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
16 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
18 import com.google.common.base.Preconditions;
19 import com.google.common.collect.ImmutableMap;
21 public class ImmutableAugmentationNodeBuilder
22 extends AbstractImmutableDataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> {
24 public static DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> create() {
25 return new ImmutableAugmentationNodeBuilder();
29 public DataContainerNodeBuilder<InstanceIdentifier.AugmentationIdentifier, AugmentationNode> withChild(
30 final DataContainerChild<?, ?> child) {
31 // Check nested augments
32 Preconditions.checkArgument(child instanceof AugmentationNode == false,
33 "Unable to add: %s, as a child for: %s, Nested augmentations are not permitted", child.getNodeType(),
34 nodeIdentifier == null ? this : nodeIdentifier);
36 return super.withChild(child);
40 public AugmentationNode build() {
41 return new ImmutableAugmentationNode(nodeIdentifier, value);
44 static final class ImmutableAugmentationNode
45 extends AbstractImmutableDataContainerNode<InstanceIdentifier.AugmentationIdentifier>
46 implements AugmentationNode {
48 ImmutableAugmentationNode(final InstanceIdentifier.AugmentationIdentifier nodeIdentifier, final Map<InstanceIdentifier.PathArgument, DataContainerChild<? extends InstanceIdentifier.PathArgument, ?>> children) {
49 super(ImmutableMap.copyOf(children), nodeIdentifier);