93823e871edaebb43f1bda8eda246d6c589d5ebb
[yangtools.git] / yang / yang-data-impl / src / main / java / org / opendaylight / yangtools / yang / data / impl / schema / builder / impl / ImmutableUnkeyedListEntryNodeBuilder.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.data.impl.schema.builder.impl;
9
10 import java.util.Map;
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.UnkeyedListEntryNode;
15 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
16 import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableDataContainerNode;
17
18 public class ImmutableUnkeyedListEntryNodeBuilder
19         extends AbstractImmutableDataContainerNodeBuilder<NodeIdentifier, UnkeyedListEntryNode> {
20
21     protected ImmutableUnkeyedListEntryNodeBuilder() {
22
23     }
24
25     protected ImmutableUnkeyedListEntryNodeBuilder(final int sizeHint) {
26         super(sizeHint);
27     }
28
29     protected ImmutableUnkeyedListEntryNodeBuilder(final ImmutableUnkeyedListEntryNode node) {
30         super(node);
31     }
32
33     public static @NonNull DataContainerNodeBuilder<NodeIdentifier, UnkeyedListEntryNode> create() {
34         return new ImmutableUnkeyedListEntryNodeBuilder();
35     }
36
37     public static @NonNull DataContainerNodeBuilder<NodeIdentifier, UnkeyedListEntryNode> create(
38             final int sizeHint) {
39         return new ImmutableUnkeyedListEntryNodeBuilder(sizeHint);
40     }
41
42     public static @NonNull DataContainerNodeBuilder<NodeIdentifier, UnkeyedListEntryNode> create(
43             final UnkeyedListEntryNode node) {
44         if (!(node instanceof ImmutableUnkeyedListEntryNode)) {
45             throw new UnsupportedOperationException(String.format("Cannot initialize from class %s", node.getClass()));
46         }
47         return new ImmutableUnkeyedListEntryNodeBuilder((ImmutableUnkeyedListEntryNode) node);
48     }
49
50     @Override
51     public UnkeyedListEntryNode build() {
52         return new ImmutableUnkeyedListEntryNode(getNodeIdentifier(), buildValue());
53     }
54
55     protected static final class ImmutableUnkeyedListEntryNode
56             extends AbstractImmutableDataContainerNode<NodeIdentifier> implements UnkeyedListEntryNode {
57
58         ImmutableUnkeyedListEntryNode(final NodeIdentifier nodeIdentifier, final Map<PathArgument, Object> children) {
59             super(children, nodeIdentifier);
60         }
61     }
62 }