f72afed490d7495bf3a8cfb867e393522db0d314
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / builder / api / DataNodeContainerBuilder.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.parser.builder.api;
9
10 import java.util.List;
11 import java.util.Map;
12 import java.util.Set;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
15 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
16 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
17 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
18 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
19
20 /**
21  * Common builder for for all YANG {@link DataNodeContainer}
22  * <code>augment, case, container,
23  * grouping, list, module, notification</code>.
24  */
25 public interface DataNodeContainerBuilder extends Builder {
26
27     /**
28      * Returns QName of this node.
29      *
30      * @return QName of this node
31      */
32     QName getQName();
33
34     /**
35      * Returns Schema path of this node.
36      *
37      * @return SchemaPath of this node
38      */
39     SchemaPath getPath();
40
41     /**
42      * Returns list of of child node builders in order they are declared in yang
43      * file.
44      *
45      * This child node builder are build, during invoking {@link #build()} and
46      * added as children to resulting {@link DataNodeContainer}.
47      *
48      * @return collection child nodes builders
49      */
50     List<DataSchemaNodeBuilder> getChildNodeBuilders();
51
52     /**
53      * Retrieves child node builder by local name.
54      *
55      * @param name
56      *            name of child to seek
57      * @return child node with given name if present, null otherwise
58      */
59     DataSchemaNodeBuilder getDataChildByName(String name);
60
61     /**
62      * Add builder of child node to this node.
63      *
64      * @param childNode name of child node to add
65      */
66     void addChildNode(DataSchemaNodeBuilder childNode);
67
68     /**
69      * Add builder of child node to this node at specified position.
70      *
71      * @param index position at which the child node will be added
72      * @param childNode name of child node to add at specified position
73      */
74     void addChildNode(int index, DataSchemaNodeBuilder childNode);
75
76     void addChildNode(DataSchemaNode childNode);
77
78     void addChildNodeToContext(DataSchemaNodeBuilder childNode);
79
80     /**
81      * Get already built groupings defined in this node.
82      *
83      * @return collection of GroupingDefinition objects
84      */
85     Set<GroupingDefinition> getGroupings();
86
87     /**
88      * Get builders of groupings defined in this node.
89      *
90      * @return collection of grouping builders
91      */
92     Set<GroupingBuilder> getGroupingBuilders();
93
94     /**
95      * Add builder of grouping statement to this node.
96      *
97      * @param groupingBuilder grouping statement builder
98      */
99     void addGrouping(GroupingBuilder groupingBuilder);
100
101     /**
102      * Get builders of uses defined in this node.
103      *
104      * @return collection of uses builders
105      */
106     List<UsesNodeBuilder> getUsesNodeBuilders();
107
108     /**
109      * Add builder of uses statement to this node.
110      *
111      * @param usesBuilder uses statement builder
112      */
113     void addUsesNode(UsesNodeBuilder usesBuilder);
114
115     /**
116      * Returns set of already built type definitions.
117      *
118      * @return set of already built type definitions.
119      */
120     Set<TypeDefinition<?>> getTypeDefinitions();
121
122     /**
123      * Returns builders of typedef statement defined in this node.
124      *
125      * @return builders of typedef statement defined in this node.
126      */
127     Set<TypeDefinitionBuilder> getTypeDefinitionBuilders();
128
129     /**
130      * Add typedef builder to this node.
131      *
132      * @param typedefBuilder
133      *            Builder to add to this node.
134      */
135     void addTypedef(TypeDefinitionBuilder typedefBuilder);
136
137     /**
138      * Returns an instance of product - DataNodeContainer
139      *
140      * Returns an instance of data node container with children and properties
141      * constructed as per this builder state, all nested builders are also built
142      * and their product is set to DataNodeContainer.
143      *
144      * @return Instance of DataNodeContainer
145      */
146     @Override
147     DataNodeContainer build();
148
149     /**
150      * Returns map of child nodes of this node. Child nodes should be in same
151      * order as they were defined in yang file.
152      *
153      * @return map of child nodes of this node
154      */
155     Map<QName, DataSchemaNode> getChildNodes();
156
157 }