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; |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +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 | */ |
| 75 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 76 | * 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] | 77 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 78 | public class YangSubModule extends YangNode |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 79 | implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Name of sub module. |
| 83 | */ |
| 84 | private String name; |
| 85 | |
| 86 | /** |
| 87 | * Module to which it belongs to. |
| 88 | */ |
| 89 | private YangBelongsTo belongsTo; |
| 90 | |
| 91 | /** |
| 92 | * Reference RFC 6020. |
| 93 | * |
| 94 | * The "contact" statement provides contact information for the module. The |
| 95 | * argument is a string that is used to specify contact information for the |
| 96 | * person or persons to whom technical queries concerning this module should |
| 97 | * be sent, such as their name, postal address, telephone number, and |
| 98 | * electronic mail address. |
| 99 | */ |
| 100 | private String contact; |
| 101 | |
| 102 | /** |
| 103 | * Description. |
| 104 | */ |
| 105 | private String description; |
| 106 | |
| 107 | /** |
| 108 | * List of YANG modules imported. |
| 109 | */ |
| 110 | private List<YangImport> importList; |
| 111 | |
| 112 | /** |
| 113 | * List of YANG sub-modules included. |
| 114 | */ |
| 115 | private List<YangInclude> includeList; |
| 116 | |
| 117 | /** |
| 118 | * List of leaves at root level in the sub-module. |
| 119 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 120 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 121 | |
| 122 | /** |
| 123 | * List of leaf-lists at root level in the sub-module. |
| 124 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 125 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 126 | |
| 127 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 128 | * Organization owner of the sub-module. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 129 | */ |
| 130 | private String organization; |
| 131 | |
| 132 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 133 | * Reference of the sub-module. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 134 | */ |
| 135 | private String reference; |
| 136 | |
| 137 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 138 | * Revision info of the sub-module. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 139 | */ |
| 140 | private YangRevision revision; |
| 141 | |
| 142 | /** |
| 143 | * YANG version. |
| 144 | */ |
| 145 | private byte version; |
| 146 | |
| 147 | /** |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 148 | * Prefix of parent module. |
| 149 | */ |
| 150 | private String prefix; |
| 151 | /*- |
| 152 | * Reference RFC 6020. |
| 153 | * |
| 154 | * Nested typedefs and groupings. |
| 155 | * Typedefs and groupings may appear nested under many YANG statements, |
| 156 | * allowing these to be lexically scoped by the hierarchy under which |
| 157 | * they appear. This allows types and groupings to be defined near |
| 158 | * where they are used, rather than placing them at the top level of the |
| 159 | * hierarchy. The close proximity increases readability. |
| 160 | * |
| 161 | * Scoping also allows types to be defined without concern for naming |
| 162 | * conflicts between types in different submodules. Type names can be |
| 163 | * specified without adding leading strings designed to prevent name |
| 164 | * collisions within large modules. |
| 165 | * |
| 166 | * Finally, scoping allows the module author to keep types and groupings |
| 167 | * private to their module or submodule, preventing their reuse. Since |
| 168 | * only top-level types and groupings (i.e., those appearing as |
| 169 | * sub-statements to a module or submodule statement) can be used outside |
| 170 | * the module or submodule, the developer has more control over what |
| 171 | * pieces of their module are presented to the outside world, supporting |
| 172 | * the need to hide internal information and maintaining a boundary |
| 173 | * between what is shared with the outside world and what is kept |
| 174 | * private. |
| 175 | * |
| 176 | * Scoped definitions MUST NOT shadow definitions at a higher scope. A |
| 177 | * type or grouping cannot be defined if a higher level in the schema |
| 178 | * hierarchy has a definition with a matching identifier. |
| 179 | * |
| 180 | * A reference to an unprefixed type or grouping, or one which uses the |
| 181 | * prefix of the current module, is resolved by locating the closest |
| 182 | * matching "typedef" or "grouping" statement among the immediate |
| 183 | * sub-statements of each ancestor statement. |
| 184 | */ |
| 185 | private List<YangResolutionInfo> unresolvedResolutionList; |
| 186 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 187 | * Creates a sub module node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 188 | */ |
| 189 | public YangSubModule() { |
| 190 | super(YangNodeType.SUB_MODULE_NODE); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 191 | unresolvedResolutionList = new LinkedList<YangResolutionInfo>(); |
| 192 | importList = new LinkedList<YangImport>(); |
| 193 | includeList = new LinkedList<YangInclude>(); |
| 194 | listOfLeaf = new LinkedList<YangLeaf>(); |
| 195 | listOfLeafList = new LinkedList<YangLeafList>(); |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 196 | } |
| 197 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 198 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 199 | * Returns the YANG name of the sub module. |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 200 | * |
| 201 | * @return YANG name of the sub module |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 202 | */ |
| 203 | @Override |
| 204 | public String getName() { |
| 205 | return name; |
| 206 | } |
| 207 | |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 208 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 209 | * Sets YANG name of the sub module. |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 210 | * |
| 211 | * @param subModuleName YANG name of the sub module |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 212 | */ |
| 213 | @Override |
| 214 | public void setName(String subModuleName) { |
| 215 | name = subModuleName; |
| 216 | } |
| 217 | |
| 218 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 219 | * Returns the module info. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 220 | * |
| 221 | * @return the belongs to info |
| 222 | */ |
| 223 | public YangBelongsTo getBelongsTo() { |
| 224 | return belongsTo; |
| 225 | } |
| 226 | |
| 227 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 228 | * Sets the module info. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 229 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 230 | * @param belongsTo module info to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 231 | */ |
| 232 | public void setBelongsTo(YangBelongsTo belongsTo) { |
| 233 | this.belongsTo = belongsTo; |
| 234 | } |
| 235 | |
| 236 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 237 | * Returns the contact. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 238 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 239 | * @return the contact |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 240 | */ |
| 241 | public String getContact() { |
| 242 | return contact; |
| 243 | } |
| 244 | |
| 245 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 246 | * Sets the contact. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 247 | * |
| 248 | * @param contact the contact to set |
| 249 | */ |
| 250 | public void setContact(String contact) { |
| 251 | this.contact = contact; |
| 252 | } |
| 253 | |
| 254 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 255 | * Returns the description. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 256 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 257 | * @return the description |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 258 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 259 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 260 | public String getDescription() { |
| 261 | return description; |
| 262 | } |
| 263 | |
| 264 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 265 | * Sets the description. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 266 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 267 | * @param description set the description |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 268 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 269 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 270 | public void setDescription(String description) { |
| 271 | this.description = description; |
| 272 | } |
| 273 | |
| 274 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 275 | * Returns the list of imported modules. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 276 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 277 | * @return the list of imported modules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 278 | */ |
| 279 | public List<YangImport> getImportList() { |
| 280 | return importList; |
| 281 | } |
| 282 | |
| 283 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 284 | * Adds the imported module information to the import list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 285 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 286 | * @param importedModule module being imported |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 287 | */ |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 288 | public void addToImportList(YangImport importedModule) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 289 | getImportList().add(importedModule); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 290 | } |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 291 | |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 292 | @Override |
| 293 | public void setImportList(List<YangImport> importList) { |
| 294 | this.importList = importList; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 298 | * Returns the list of included sub modules. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 299 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 300 | * @return the included list of sub modules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 301 | */ |
| 302 | public List<YangInclude> getIncludeList() { |
| 303 | return includeList; |
| 304 | } |
| 305 | |
| 306 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 307 | * Returns the included sub module information to the include list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 308 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 309 | * @param includeModule submodule being included |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 310 | */ |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 311 | public void addToIncludeList(YangInclude includeModule) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 312 | getIncludeList().add(includeModule); |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | @Override |
| 316 | public void setIncludeList(List<YangInclude> includeList) { |
| 317 | this.includeList = includeList; |
| 318 | } |
| 319 | |
| 320 | @Override |
| 321 | public String getPrefix() { |
| 322 | return prefix; |
| 323 | } |
| 324 | |
| 325 | @Override |
| 326 | public void setPrefix(String prefix) { |
| 327 | this.prefix = prefix; |
| 328 | } |
| 329 | |
| 330 | @Override |
| 331 | public void resolveSelfFileLinking() throws DataModelException { |
| 332 | // Get the list to be resolved. |
| 333 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(); |
| 334 | // Resolve linking for a resolution list. |
| 335 | resolveLinkingForResolutionList(resolutionList, this); |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 339 | * Returns the list of leaves. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 340 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 341 | * @return the list of leaves |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 342 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 343 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 344 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 345 | return listOfLeaf; |
| 346 | } |
| 347 | |
| 348 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 349 | * Adds a leaf. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 350 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 351 | * @param leaf the leaf to be added |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 352 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 353 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 354 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 355 | getListOfLeaf().add(leaf); |
| 356 | } |
| 357 | |
| 358 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 359 | * Returns the list of leaf-list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 360 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 361 | * @return the list of leaf-list |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 362 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 363 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 364 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 365 | return listOfLeafList; |
| 366 | } |
| 367 | |
| 368 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 369 | * Adds a leaf-list. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 370 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 371 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 372 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 373 | @Override |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 374 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 375 | getListOfLeafList().add(leafList); |
| 376 | } |
| 377 | |
| 378 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 379 | * Returns the sub-modules organization. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 380 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 381 | * @return the organization |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 382 | */ |
| 383 | public String getOrganization() { |
| 384 | return organization; |
| 385 | } |
| 386 | |
| 387 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 388 | * Sets the sub-modules organization. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 389 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 390 | * @param org the organization to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 391 | */ |
| 392 | public void setOrganization(String org) { |
| 393 | organization = org; |
| 394 | } |
| 395 | |
| 396 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 397 | * Returns the textual reference. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 398 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 399 | * @return the reference |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 400 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 401 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 402 | public String getReference() { |
| 403 | return reference; |
| 404 | } |
| 405 | |
| 406 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 407 | * Sets the textual reference. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 408 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 409 | * @param reference the reference to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 410 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 411 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 412 | public void setReference(String reference) { |
| 413 | this.reference = reference; |
| 414 | } |
| 415 | |
| 416 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 417 | * Returns the revision. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 418 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 419 | * @return the revision |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 420 | */ |
| 421 | public YangRevision getRevision() { |
| 422 | return revision; |
| 423 | } |
| 424 | |
| 425 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 426 | * Sets the revision. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 427 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 428 | * @param revision the revision to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 429 | */ |
| 430 | public void setRevision(YangRevision revision) { |
| 431 | this.revision = revision; |
| 432 | } |
| 433 | |
| 434 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 435 | * Returns the version. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 436 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 437 | * @return the version |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 438 | */ |
| 439 | public byte getVersion() { |
| 440 | return version; |
| 441 | } |
| 442 | |
| 443 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 444 | * Sets the version. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 445 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 446 | * @param version the version to set |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 447 | */ |
| 448 | public void setVersion(byte version) { |
| 449 | this.version = version; |
| 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Returns the type of the parsed data. |
| 454 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 455 | * @return returns SUB_MODULE_DATA |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 456 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 457 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 458 | public YangConstructType getYangConstructType() { |
| 459 | return YangConstructType.SUB_MODULE_DATA; |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 460 | } |
| 461 | |
| 462 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 463 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 464 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 465 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 466 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 467 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 468 | public void validateDataOnEntry() throws DataModelException { |
| 469 | // TODO auto-generated method stub, to be implemented by parser |
| 470 | } |
| 471 | |
| 472 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 473 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 474 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 475 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 476 | */ |
Bharat saraswal | 9745996 | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 477 | @Override |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 478 | public void validateDataOnExit() throws DataModelException { |
| 479 | // TODO auto-generated method stub, to be implemented by parser |
| 480 | } |
| 481 | |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 482 | @Override |
| 483 | public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException { |
| 484 | // Asks helper to detect colliding child. |
| 485 | detectCollidingChildUtil(identifierName, dataType, this); |
| 486 | } |
| 487 | |
| 488 | @Override |
| 489 | public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException { |
| 490 | // Not required as module doesn't have any parent. |
| 491 | } |
Gaurav Agrawal | 1fbfae1 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 492 | |
| 493 | @Override |
| 494 | public List<YangResolutionInfo> getUnresolvedResolutionList() { |
| 495 | return unresolvedResolutionList; |
| 496 | } |
| 497 | |
| 498 | @Override |
| 499 | public void addToResolutionList(YangResolutionInfo resolutionInfo) { |
| 500 | this.unresolvedResolutionList.add(resolutionInfo); |
| 501 | } |
| 502 | |
| 503 | @Override |
| 504 | public void setResolutionList(List<YangResolutionInfo> resolutionList) { |
| 505 | this.unresolvedResolutionList = resolutionList; |
| 506 | } |
Vinod Kumar S | 6a6ce4c | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 507 | } |