2 * Copyright (c) 2014 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;
10 import org.opendaylight.yangtools.yang.common.QName;
11 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
13 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
18 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
19 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
20 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
21 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
22 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
23 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
24 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
26 public final class ImmutableNodes {
28 private ImmutableNodes() {
29 throw new UnsupportedOperationException("Utilities class should not be instantiated");
32 public static CollectionNodeBuilder<MapEntryNode, MapNode> mapNodeBuilder() {
33 return ImmutableMapNodeBuilder.create();
36 public static CollectionNodeBuilder<MapEntryNode, MapNode> mapNodeBuilder(final QName name) {
37 return ImmutableMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(name));
41 * Construct immutable leaf node
43 * @param name Identifier of leaf node
44 * @param value Value of leaf node
45 * @return Leaf node with supplied identifier and value
47 public static <T> LeafNode<T> leafNode(final NodeIdentifier name,final T value) {
48 return ImmutableLeafNodeBuilder.<T>create()
49 .withNodeIdentifier(name)
55 * Construct immutable leaf node
57 * @param name QName which will be used as node identifier
58 * @param value Value of leaf node.
59 * @return Leaf node with supplied identifier and value
61 public static <T> LeafNode<T> leafNode(final QName name,final T value) {
62 return leafNode(new NodeIdentifier(name), value);
65 public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder(final QName nodeName, final QName keyName, final Object keyValue) {
66 return ImmutableMapEntryNodeBuilder.create()
67 .withNodeIdentifier(new NodeIdentifierWithPredicates(nodeName, keyName, keyValue))
68 .withChild(leafNode(keyName, keyValue));
71 public static MapEntryNode mapEntry(final QName nodeName,final QName keyName,final Object keyValue) {
72 return mapEntryBuilder(nodeName, keyName, keyValue).build();
75 public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder() {
76 return ImmutableMapEntryNodeBuilder.create();
79 public static ContainerNode containerNode(final QName name) {
80 return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(name)).build();
83 public static ChoiceNode choiceNode(final QName name) {
84 return ImmutableChoiceNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(name)).build();