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.LeafNode;
14 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
15 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
18 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
19 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
20 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
21 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
22 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapNodeBuilder;
24 public final class ImmutableNodes {
26 private ImmutableNodes() {
27 throw new UnsupportedOperationException("Utilities class should not be instantiated");
30 public static final CollectionNodeBuilder<MapEntryNode, MapNode> mapNodeBuilder() {
31 return ImmutableMapNodeBuilder.create();
34 public static final CollectionNodeBuilder<MapEntryNode, MapNode> mapNodeBuilder(final QName name) {
35 return ImmutableMapNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(name));
39 * Construct immutable leaf node
41 * @param name Identifier of leaf node
42 * @param value Value of leaf node
43 * @return Leaf node with supplied identifier and value
45 public static final <T> LeafNode<T> leafNode(final NodeIdentifier name,final T value) {
46 return ImmutableLeafNodeBuilder.<T>create()
47 .withNodeIdentifier(name)
54 * Construct immutable leaf node
56 * @param name QName which will be used as node identifier
57 * @param value Value of leaf node.
58 * @return Leaf node with supplied identifier and value
60 public static final <T> LeafNode<T> leafNode(final QName name,final T value) {
61 return leafNode(new NodeIdentifier(name), value);
64 public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder(final QName nodeName,final QName keyName,final Object keyValue) {
65 return ImmutableMapEntryNodeBuilder.create()
66 .withNodeIdentifier(new NodeIdentifierWithPredicates(nodeName, keyName,keyValue))
67 .withChild(leafNode(keyName, keyValue));
70 public static MapEntryNode mapEntry(final QName nodeName,final QName keyName,final Object keyValue) {
71 return mapEntryBuilder(nodeName, keyName, keyValue).build();
74 public static DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder() {
75 return ImmutableMapEntryNodeBuilder.create();
78 public static NormalizedNode<?, ?> containerNode(final QName name) {
79 return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(name)).build();