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.ContainerNode;
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 ImmutableContainerNodeBuilder
19 extends AbstractImmutableDataContainerNodeBuilder<NodeIdentifier, ContainerNode> {
21 protected ImmutableContainerNodeBuilder() {
25 protected ImmutableContainerNodeBuilder(final int sizeHint) {
29 protected ImmutableContainerNodeBuilder(final ImmutableContainerNode node) {
33 public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ContainerNode> create() {
34 return new ImmutableContainerNodeBuilder();
37 public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ContainerNode> create(final int sizeHint) {
38 return new ImmutableContainerNodeBuilder(sizeHint);
41 public static @NonNull DataContainerNodeBuilder<NodeIdentifier, ContainerNode> create(
42 final ContainerNode node) {
43 if (!(node instanceof ImmutableContainerNode)) {
44 throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
46 return new ImmutableContainerNodeBuilder((ImmutableContainerNode) node);
50 public ContainerNode build() {
51 return new ImmutableContainerNode(getNodeIdentifier(), buildValue());
54 protected static final class ImmutableContainerNode extends AbstractImmutableDataContainerNode<NodeIdentifier>
55 implements ContainerNode {
57 ImmutableContainerNode(final NodeIdentifier nodeIdentifier, final Map<PathArgument, Object> children) {
58 super(children, nodeIdentifier);