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.YangInstanceIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
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 public class ImmutableChoiceNodeBuilder extends AbstractImmutableDataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> {
20 protected ImmutableChoiceNodeBuilder() {
24 protected ImmutableChoiceNodeBuilder(final int sizeHint) {
28 protected ImmutableChoiceNodeBuilder(final ImmutableChoiceNode node) {
32 public static DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> create() {
33 return new ImmutableChoiceNodeBuilder();
36 public static DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> create(final int sizeHint) {
37 return new ImmutableChoiceNodeBuilder(sizeHint);
40 public static DataContainerNodeBuilder<YangInstanceIdentifier.NodeIdentifier, ChoiceNode> create(final ChoiceNode node) {
41 if (!(node instanceof ImmutableChoiceNode)) {
42 throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
45 return new ImmutableChoiceNodeBuilder((ImmutableChoiceNode)node);
49 public ChoiceNode build() {
50 return new ImmutableChoiceNode(getNodeIdentifier(), buildValue());
53 private static final class ImmutableChoiceNode extends AbstractImmutableDataContainerNode<YangInstanceIdentifier.NodeIdentifier> implements ChoiceNode {
55 ImmutableChoiceNode(final YangInstanceIdentifier.NodeIdentifier nodeIdentifier,
56 final Map<YangInstanceIdentifier.PathArgument, DataContainerChild<? extends YangInstanceIdentifier.PathArgument, ?>> children) {
57 super(children, nodeIdentifier);