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;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
16 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
18 public class ImmutableChoiceNodeBuilder extends AbstractImmutableDataContainerNodeBuilder<NodeIdentifier, ChoiceNode> {
19 protected ImmutableChoiceNodeBuilder() {
23 protected ImmutableChoiceNodeBuilder(final int sizeHint) {
27 protected ImmutableChoiceNodeBuilder(final ImmutableChoiceNode node) {
31 public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> create() {
32 return new ImmutableChoiceNodeBuilder();
35 public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> create(final int sizeHint) {
36 return new ImmutableChoiceNodeBuilder(sizeHint);
39 public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> create(final ChoiceNode node) {
40 if (!(node instanceof ImmutableChoiceNode immutableNode)) {
41 throw new UnsupportedOperationException("Cannot initialize from class " + node.getClass());
43 return new ImmutableChoiceNodeBuilder(immutableNode);
47 public ChoiceNode build() {
48 return new ImmutableChoiceNode(getNodeIdentifier(), buildValue());
51 private static final class ImmutableChoiceNode
52 extends AbstractImmutableDataContainerNode<NodeIdentifier, ChoiceNode> implements ChoiceNode {
53 ImmutableChoiceNode(final NodeIdentifier nodeIdentifier, final Map<PathArgument, Object> children) {
54 super(children, nodeIdentifier);
58 protected Class<ChoiceNode> implementedType() {
59 return ChoiceNode.class;