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