Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.yangutils.datamodel; |
| 17 | |
| 18 | import java.util.LinkedList; |
| 19 | import java.util.List; |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame^] | 20 | |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 21 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 22 | import org.onosproject.yangutils.parser.Parsable; |
| 23 | import org.onosproject.yangutils.utils.YangConstructType; |
| 24 | |
| 25 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 26 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList; |
Vinod Kumar S | 9f26ae5 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 27 | |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 28 | /* |
| 29 | * Reference RFC 6020. |
| 30 | * |
| 31 | * While the primary unit in YANG is a module, a YANG module can itself |
| 32 | * be constructed out of several submodules. Submodules allow a module |
| 33 | * designer to split a complex model into several pieces where all the |
| 34 | * submodules contribute to a single namespace, which is defined by the |
| 35 | * module that includes the submodules. |
| 36 | * |
| 37 | * The "submodule" statement defines the submodule's name, and groups |
| 38 | * all statements that belong to the submodule together. The |
| 39 | * "submodule" statement's argument is the name of the submodule, |
| 40 | * followed by a block of sub-statements that hold detailed submodule |
| 41 | * information. |
| 42 | * |
| 43 | * The submodule's sub-statements |
| 44 | * |
| 45 | * +--------------+---------+-------------+------------------+ |
| 46 | * | substatement | section | cardinality |data model mapping| |
| 47 | * +--------------+---------+-------------+------------------+ |
| 48 | * | anyxml | 7.10 | 0..n | - not supported | |
| 49 | * | augment | 7.15 | 0..n | - child nodes | |
| 50 | * | belongs-to | 7.2.2 | 1 | - YangBelongsTo | |
| 51 | * | choice | 7.9 | 0..n | - child nodes | |
| 52 | * | contact | 7.1.8 | 0..1 | - string | |
| 53 | * | container | 7.5 | 0..n | - child nodes | |
| 54 | * | description | 7.19.3 | 0..1 | - string | |
| 55 | * | deviation | 7.18.3 | 0..n | - TODO | |
| 56 | * | extension | 7.17 | 0..n | - TODO | |
| 57 | * | feature | 7.18.1 | 0..n | - TODO | |
| 58 | * | grouping | 7.11 | 0..n | - child nodes | |
| 59 | * | identity | 7.16 | 0..n | - TODO | |
| 60 | * | import | 7.1.5 | 0..n | - YangImport | |
| 61 | * | include | 7.1.6 | 0..n | - YangInclude | |
| 62 | * | leaf | 7.6 | 0..n | - YangLeaf | |
| 63 | * | leaf-list | 7.7 | 0..n | - YangLeafList | |
| 64 | * | list | 7.8 | 0..n | - child nodes | |
| 65 | * | notification | 7.14 | 0..n | - TODO | |
| 66 | * | organization | 7.1.7 | 0..1 | - string | |
| 67 | * | reference | 7.19.4 | 0..1 | - string | |
| 68 | * | revision | 7.1.9 | 0..n | - string | |
| 69 | * | rpc | 7.13 | 0..n | - TODO | |
| 70 | * | typedef | 7.3 | 0..n | - child nodes | |
| 71 | * | uses | 7.12 | 0..n | - child nodes | |
| 72 | * | YANG-version | 7.1.2 | 0..1 | - int | |
| 73 | * +--------------+---------+-------------+------------------+ |
| 74 | */ |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 75 | |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 76 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 77 | * Represents data model node to maintain information defined in YANG sub-module. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 78 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 79 | public class YangSubModule extends YangNode |
Vinod Kumar S | 79a374b | 2016-04-30 21:09:15 +0530 | [diff] [blame^] | 80 | implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, |
| 81 | RpcNotificationContainer { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 82 | |
| 83 | /** |
| 84 | * Name of sub module. |
| 85 | */ |
| 86 | private String name; |
| 87 | |
| 88 | /** |
| 89 | * Module to which it belongs to. |
| 90 | */ |
| 91 | private YangBelongsTo belongsTo; |
| 92 | |
| 93 | /** |
| 94 | * Reference RFC 6020. |
| 95 | * |
| 96 | * The "contact" statement provides contact information for the module. The |
| 97 | * argument is a string that is used to specify contact information for the |
| 98 | * person or persons to whom technical queries concerning this module should |
| 99 | * be sent, such as their name, postal address, telephone number, and |
| 100 | * electronic mail address. |
| 101 | */ |
| 102 | private String contact; |
| 103 | |
| 104 | /** |
| 105 | * Description. |
| 106 | */ |
| 107 | private String description; |
| 108 | |
| 109 | /** |
| 110 | * List of YANG modules imported. |
| 111 | */ |
| 112 | private List<YangImport> importList; |
| 113 | |
| 114 | /** |
| 115 | * List of YANG sub-modules included. |
| 116 | */ |
| 117 | private List<YangInclude> includeList; |
| 118 | |
| 119 | /** |
| 120 | * List of leaves at root level in the sub-module. |
| 121 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 122 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * List of leaf-lists at root level in the sub-module. |
| 126 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 127 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 128 | |
| 129 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 130 | * Organization owner of the sub-module. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 131 | */ |
| 132 | private String organization; |
| 133 | |
| 134 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 135 | * Reference of the sub-module. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 136 | */ |
| 137 | private String reference; |
| 138 | |
| 139 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 140 | * Revision info of the sub-module. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 141 | */ |
| 142 | private YangRevision revision; |
| 143 | |
| 144 | /** |
| 145 | * YANG version. |
| 146 | */ |
| 147 | private byte version; |
| 148 | |
| 149 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 150 | * Prefix of parent module. |
| 151 | */ |
| 152 | private String prefix; |
| 153 | /*- |
| 154 | * Reference RFC 6020. |
| 155 | * |
| 156 | * Nested typedefs and groupings. |
| 157 | * Typedefs and groupings may appear nested under many YANG statements, |
| 158 | * allowing these to be lexically scoped by the hierarchy under which |
| 159 | * they appear. This allows types and groupings to be defined near |
| 160 | * where they are used, rather than placing them at the top level of the |
| 161 | * hierarchy. The close proximity increases readability. |
| 162 | * |
| 163 | * Scoping also allows types to be defined without concern for naming |
| 164 | * conflicts between types in different submodules. Type names can be |
| 165 | * specified without adding leading strings designed to prevent name |
| 166 | * collisions within large modules. |
| 167 | * |
| 168 | * Finally, scoping allows the module author to keep types and groupings |
| 169 | * private to their module or submodule, preventing their reuse. Since |
| 170 | * only top-level types and groupings (i.e., those appearing as |
| 171 | * sub-statements to a module or submodule statement) can be used outside |
| 172 | * the module or submodule, the developer has more control over what |
| 173 | * pieces of their module are presented to the outside world, supporting |
| 174 | * the need to hide internal information and maintaining a boundary |
| 175 | * between what is shared with the outside world and what is kept |
| 176 | * private. |
| 177 | * |
| 178 | * Scoped definitions MUST NOT shadow definitions at a higher scope. A |
| 179 | * type or grouping cannot be defined if a higher level in the schema |
| 180 | * hierarchy has a definition with a matching identifier. |
| 181 | * |
| 182 | * A reference to an unprefixed type or grouping, or one which uses the |
| 183 | * prefix of the current module, is resolved by locating the closest |
| 184 | * matching "typedef" or "grouping" statement among the immediate |
| 185 | * sub-statements of each ancestor statement. |
| 186 | */ |
| 187 | private List<YangResolutionInfo> unresolvedResolutionList; |
Gaurav Agrawal | 02a60de | 2016-04-20 15:49:17 +0530 | [diff] [blame] | 188 | |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 189 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 190 | * Creates a sub module node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 191 | */ |
| 192 | public YangSubModule() { |
| 193 | super(YangNodeType.SUB_MODULE_NODE); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 194 | unresolvedResolutionList = new LinkedList<YangResolutionInfo>(); |
| 195 | importList = new LinkedList<YangImport>(); |
| 196 | includeList = new LinkedList<YangInclude>(); |
| 197 | listOfLeaf = new LinkedList<YangLeaf>(); |
| 198 | listOfLeafList = new LinkedList<YangLeafList>(); |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 199 | } |
| 200 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 201 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 202 | * Returns the YANG name of the sub module. |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 203 | * |
| 204 | * @return YANG name of the sub module |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 205 | */ |
| 206 | @Override |
| 207 | public String getName() { |
| 208 | return name; |
| 209 | } |
| 210 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 211 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 212 | * Sets YANG name of the sub module. |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 213 | * |
| 214 | * @param subModuleName YANG name of the sub module |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 215 | */ |
| 216 | @Override |
| 217 | public void setName(String subModuleName) { |
| 218 | name = subModuleName; |
| 219 | } |
| 220 | |
| 221 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 222 | * Returns the module info. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 223 | * |
| 224 | * @return the belongs to info |
| 225 | */ |
| 226 | public YangBelongsTo getBelongsTo() { |
| 227 | return belongsTo; |
| 228 | } |
| 229 | |
| 230 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 231 | * Sets the module info. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 232 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 233 | * @param belongsTo module info to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 234 | */ |
| 235 | public void setBelongsTo(YangBelongsTo belongsTo) { |
| 236 | this.belongsTo = belongsTo; |
| 237 | } |
| 238 | |
| 239 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 240 | * Returns the contact. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 241 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 242 | * @return the contact |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 243 | */ |
| 244 | public String getContact() { |
| 245 | return contact; |
| 246 | } |
| 247 | |
| 248 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 249 | * Sets the contact. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 250 | * |
| 251 | * @param contact the contact to set |
| 252 | */ |
| 253 | public void setContact(String contact) { |
| 254 | this.contact = contact; |
| 255 | } |
| 256 | |
| 257 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 258 | * Returns the description. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 259 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 260 | * @return the description |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 261 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 262 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 263 | public String getDescription() { |
| 264 | return description; |
| 265 | } |
| 266 | |
| 267 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 268 | * Sets the description. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 269 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 270 | * @param description set the description |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 271 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 272 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 273 | public void setDescription(String description) { |
| 274 | this.description = description; |
| 275 | } |
| 276 | |
| 277 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 278 | * Returns the list of imported modules. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 279 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 280 | * @return the list of imported modules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 281 | */ |
| 282 | public List<YangImport> getImportList() { |
| 283 | return importList; |
| 284 | } |
| 285 | |
| 286 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 287 | * Adds the imported module information to the import list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 288 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 289 | * @param importedModule module being imported |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 290 | */ |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 291 | public void addToImportList(YangImport importedModule) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 292 | getImportList().add(importedModule); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 293 | } |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 294 | |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 295 | @Override |
| 296 | public void setImportList(List<YangImport> importList) { |
| 297 | this.importList = importList; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 301 | * Returns the list of included sub modules. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 302 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 303 | * @return the included list of sub modules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 304 | */ |
| 305 | public List<YangInclude> getIncludeList() { |
| 306 | return includeList; |
| 307 | } |
| 308 | |
| 309 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 310 | * Returns the included sub module information to the include list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 311 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 312 | * @param includeModule submodule being included |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 313 | */ |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 314 | public void addToIncludeList(YangInclude includeModule) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 315 | getIncludeList().add(includeModule); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | @Override |
| 319 | public void setIncludeList(List<YangInclude> includeList) { |
| 320 | this.includeList = includeList; |
| 321 | } |
| 322 | |
| 323 | @Override |
| 324 | public String getPrefix() { |
| 325 | return prefix; |
| 326 | } |
| 327 | |
| 328 | @Override |
| 329 | public void setPrefix(String prefix) { |
| 330 | this.prefix = prefix; |
| 331 | } |
| 332 | |
| 333 | @Override |
| 334 | public void resolveSelfFileLinking() throws DataModelException { |
| 335 | // Get the list to be resolved. |
| 336 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); |
| 337 | // Resolve linking for a resolution list. |
| 338 | resolveLinkingForResolutionList(resolutionList, this); |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 342 | * Returns the list of leaves. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 343 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 344 | * @return the list of leaves |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 345 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 346 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 347 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 348 | return listOfLeaf; |
| 349 | } |
| 350 | |
| 351 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 352 | * Adds a leaf. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 353 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 354 | * @param leaf the leaf to be added |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 355 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 356 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 357 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 358 | getListOfLeaf().add(leaf); |
| 359 | } |
| 360 | |
| 361 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 362 | * Returns the list of leaf-list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 363 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 364 | * @return the list of leaf-list |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 365 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 366 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 367 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 368 | return listOfLeafList; |
| 369 | } |
| 370 | |
| 371 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 372 | * Adds a leaf-list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 373 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 374 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 375 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 376 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 377 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 378 | getListOfLeafList().add(leafList); |
| 379 | } |
| 380 | |
| 381 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 382 | * Returns the sub-modules organization. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 383 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 384 | * @return the organization |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 385 | */ |
| 386 | public String getOrganization() { |
| 387 | return organization; |
| 388 | } |
| 389 | |
| 390 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 391 | * Sets the sub-modules organization. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 392 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 393 | * @param org the organization to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 394 | */ |
| 395 | public void setOrganization(String org) { |
| 396 | organization = org; |
| 397 | } |
| 398 | |
| 399 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 400 | * Returns the textual reference. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 401 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 402 | * @return the reference |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 403 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 404 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 405 | public String getReference() { |
| 406 | return reference; |
| 407 | } |
| 408 | |
| 409 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 410 | * Sets the textual reference. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 411 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 412 | * @param reference the reference to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 413 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 414 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 415 | public void setReference(String reference) { |
| 416 | this.reference = reference; |
| 417 | } |
| 418 | |
| 419 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 420 | * Returns the revision. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 421 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 422 | * @return the revision |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 423 | */ |
| 424 | public YangRevision getRevision() { |
| 425 | return revision; |
| 426 | } |
| 427 | |
| 428 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 429 | * Sets the revision. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 430 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 431 | * @param revision the revision to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 432 | */ |
| 433 | public void setRevision(YangRevision revision) { |
| 434 | this.revision = revision; |
| 435 | } |
| 436 | |
| 437 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 438 | * Returns the version. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 439 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 440 | * @return the version |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 441 | */ |
| 442 | public byte getVersion() { |
| 443 | return version; |
| 444 | } |
| 445 | |
| 446 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 447 | * Sets the version. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 448 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 449 | * @param version the version to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 450 | */ |
| 451 | public void setVersion(byte version) { |
| 452 | this.version = version; |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * Returns the type of the parsed data. |
| 457 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 458 | * @return returns SUB_MODULE_DATA |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 459 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 460 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 461 | public YangConstructType getYangConstructType() { |
| 462 | return YangConstructType.SUB_MODULE_DATA; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 466 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 467 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 468 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 469 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 470 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 471 | public void validateDataOnEntry() throws DataModelException { |
| 472 | // TODO auto-generated method stub, to be implemented by parser |
| 473 | } |
| 474 | |
| 475 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 476 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 477 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 478 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 479 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 480 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 481 | public void validateDataOnExit() throws DataModelException { |
| 482 | // TODO auto-generated method stub, to be implemented by parser |
| 483 | } |
| 484 | |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 485 | @Override |
| 486 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { |
| 487 | // Asks helper to detect colliding child. |
| 488 | detectCollidingChildUtil(identifierName, dataType, this); |
| 489 | } |
| 490 | |
| 491 | @Override |
| 492 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { |
| 493 | // Not required as module doesn't have any parent. |
| 494 | } |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 495 | |
| 496 | @Override |
| 497 | public List<YangResolutionInfo> getUnresolvedResolutionList() { |
| 498 | return unresolvedResolutionList; |
| 499 | } |
| 500 | |
| 501 | @Override |
| 502 | public void addToResolutionList(YangResolutionInfo resolutionInfo) { |
| 503 | this.unresolvedResolutionList.add(resolutionInfo); |
| 504 | } |
| 505 | |
| 506 | @Override |
| 507 | public void setResolutionList(List<YangResolutionInfo> resolutionList) { |
| 508 | this.unresolvedResolutionList = resolutionList; |
| 509 | } |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 510 | } |