Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +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 | |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 18 | import java.util.Iterator; |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 19 | import java.util.LinkedList; |
| 20 | import java.util.List; |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 21 | import java.util.Set; |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.parser.Parsable; |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.utils.YangConstructType; |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 25 | |
| 26 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil; |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 27 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.linkInterFileReferences; |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 28 | import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList; |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 29 | |
| 30 | /*- |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 31 | * Reference:RFC 6020. |
| 32 | * The "module" statement defines the module's name, |
| 33 | * and groups all statements that belong to the module together. The "module" |
| 34 | * statement's argument is the name of the module, followed by a block of |
| 35 | * sub statements that hold detailed module information. |
| 36 | * The module's sub statements |
| 37 | * |
| 38 | * +--------------+---------+-------------+-----------------------+ |
| 39 | * |sub statement | section | cardinality | data model mapping | |
| 40 | * +--------------+---------+-------------+-----------------------+ |
| 41 | * | anyxml | 7.10 | 0..n | not supported | |
| 42 | * | augment | 7.15 | 0..n | child nodes | |
| 43 | * | choice | 7.9 | 0..n | child nodes | |
| 44 | * | contact | 7.1.8 | 0..1 | string | |
| 45 | * | container | 7.5 | 0..n | child nodes | |
| 46 | * | description | 7.19.3 | 0..1 | string | |
| 47 | * | deviation | 7.18.3 | 0..n | TODO | |
| 48 | * | extension | 7.17 | 0..n | TODO | |
| 49 | * | feature | 7.18.1 | 0..n | TODO | |
| 50 | * | grouping | 7.11 | 0..n | child nodes | |
| 51 | * | identity | 7.16 | 0..n | TODO | |
| 52 | * | import | 7.1.5 | 0..n | list of import info | |
| 53 | * | include | 7.1.6 | 0..n | list of include info | |
| 54 | * | leaf | 7.6 | 0..n | list of leaf info | |
| 55 | * | leaf-list | 7.7 | 0..n | list of leaf-list info| |
| 56 | * | list | 7.8 | 0..n | child nodes | |
| 57 | * | namespace | 7.1.3 | 1 | string/uri | |
| 58 | * | notification | 7.14 | 0..n | TODO | |
| 59 | * | organization | 7.1.7 | 0..1 | string | |
| 60 | * | prefix | 7.1.4 | 1 | string | |
| 61 | * | reference | 7.19.4 | 0..1 | string | |
| 62 | * | revision | 7.1.9 | 0..n | revision | |
| 63 | * | rpc | 7.13 | 0..n | TODO | |
| 64 | * | typedef | 7.3 | 0..n | child nodes | |
| 65 | * | uses | 7.12 | 0..n | child nodes | |
| 66 | * | YANG-version | 7.1.2 | 0..1 | int | |
| 67 | * +--------------+---------+-------------+-----------------------+ |
| 68 | */ |
| 69 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 70 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 71 | * Represents data model node to maintain information defined in YANG module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 72 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 73 | public class YangModule |
| 74 | extends YangNode |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 75 | implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, YangReferenceResolver, |
| 76 | RpcNotificationContainer { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 77 | |
| 78 | /** |
| 79 | * Name of the module. |
| 80 | */ |
| 81 | private String name; |
| 82 | |
| 83 | /** |
| 84 | * Reference:RFC 6020. |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 85 | * <p> |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 86 | * The "contact" statement provides contact information for the module. The |
| 87 | * argument is a string that is used to specify contact information for the |
| 88 | * person or persons to whom technical queries concerning this module should |
| 89 | * be sent, such as their name, postal address, telephone number, and |
| 90 | * electronic mail address. |
| 91 | */ |
| 92 | private String contact; |
| 93 | |
| 94 | /** |
| 95 | * Reference:RFC 6020. |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 96 | * <p> |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 97 | * The "description" statement takes as an argument a string that contains a |
| 98 | * human-readable textual description of this definition. The text is |
| 99 | * provided in a language (or languages) chosen by the module developer; for |
| 100 | * the sake of interoperability. |
| 101 | */ |
| 102 | private String description; |
| 103 | |
| 104 | /** |
| 105 | * List of YANG modules imported. |
| 106 | */ |
| 107 | private List<YangImport> importList; |
| 108 | |
| 109 | /** |
| 110 | * List of YANG sub-modules included. |
| 111 | */ |
| 112 | private List<YangInclude> includeList; |
| 113 | |
| 114 | /** |
| 115 | * List of leaves at root level in the module. |
| 116 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 117 | private List<YangLeaf> listOfLeaf; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 118 | |
| 119 | /** |
| 120 | * List of leaf-lists at root level in the module. |
| 121 | */ |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 122 | private List<YangLeafList> listOfLeafList; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Name space of the module. |
| 126 | */ |
| 127 | private YangNameSpace nameSpace; |
| 128 | |
| 129 | /** |
| 130 | * Reference:RFC 6020. |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 131 | * <p> |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 132 | * The "organization" statement defines the party responsible for this |
| 133 | * module. The argument is a string that is used to specify a textual |
| 134 | * description of the organization(s) under whose auspices this module was |
| 135 | * developed. |
| 136 | */ |
| 137 | private String organization; |
| 138 | |
| 139 | /** |
| 140 | * Prefix to refer to the objects in module. |
| 141 | */ |
| 142 | private String prefix; |
| 143 | |
| 144 | /** |
| 145 | * Reference of the module. |
| 146 | */ |
| 147 | private String reference; |
| 148 | |
| 149 | /** |
| 150 | * Revision info of the module. |
| 151 | */ |
| 152 | private YangRevision revision; |
| 153 | |
| 154 | /** |
| 155 | * YANG version. |
| 156 | */ |
| 157 | private byte version; |
| 158 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 159 | /*- |
Vinod Kumar S | c421600 | 2016-03-03 19:55:30 +0530 | [diff] [blame] | 160 | * Reference RFC 6020. |
| 161 | * |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 162 | * Nested typedefs and groupings. |
| 163 | * Typedefs and groupings may appear nested under many YANG statements, |
| 164 | * allowing these to be lexically scoped by the hierarchy under which |
| 165 | * they appear. This allows types and groupings to be defined near |
| 166 | * where they are used, rather than placing them at the top level of the |
| 167 | * hierarchy. The close proximity increases readability. |
| 168 | * |
| 169 | * Scoping also allows types to be defined without concern for naming |
| 170 | * conflicts between types in different submodules. Type names can be |
| 171 | * specified without adding leading strings designed to prevent name |
| 172 | * collisions within large modules. |
| 173 | * |
| 174 | * Finally, scoping allows the module author to keep types and groupings |
| 175 | * private to their module or submodule, preventing their reuse. Since |
| 176 | * only top-level types and groupings (i.e., those appearing as |
| 177 | * sub-statements to a module or submodule statement) can be used outside |
| 178 | * the module or submodule, the developer has more control over what |
| 179 | * pieces of their module are presented to the outside world, supporting |
| 180 | * the need to hide internal information and maintaining a boundary |
| 181 | * between what is shared with the outside world and what is kept |
| 182 | * private. |
| 183 | * |
| 184 | * Scoped definitions MUST NOT shadow definitions at a higher scope. A |
| 185 | * type or grouping cannot be defined if a higher level in the schema |
| 186 | * hierarchy has a definition with a matching identifier. |
| 187 | * |
| 188 | * A reference to an unprefixed type or grouping, or one which uses the |
| 189 | * prefix of the current module, is resolved by locating the closest |
| 190 | * matching "typedef" or "grouping" statement among the immediate |
| 191 | * sub-statements of each ancestor statement. |
| 192 | */ |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 193 | private List<YangResolutionInfo> derivedTypeResolutionList; |
| 194 | |
| 195 | /** |
| 196 | * uses resolution list. |
| 197 | */ |
| 198 | private List<YangResolutionInfo> usesResolutionList; |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 199 | |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 200 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 201 | * Creates a YANG node of module type. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 202 | */ |
| 203 | public YangModule() { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 204 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 205 | super(YangNodeType.MODULE_NODE); |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 206 | derivedTypeResolutionList = new LinkedList<>(); |
| 207 | usesResolutionList = new LinkedList<>(); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 208 | importList = new LinkedList<YangImport>(); |
| 209 | includeList = new LinkedList<YangInclude>(); |
| 210 | listOfLeaf = new LinkedList<YangLeaf>(); |
| 211 | listOfLeafList = new LinkedList<YangLeafList>(); |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 212 | } |
| 213 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 214 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 215 | * Returns name of the module. |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 216 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 217 | * @return module name |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 218 | */ |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 219 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 220 | public String getName() { |
| 221 | return name; |
| 222 | } |
| 223 | |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 224 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 225 | * Sets module name. |
Vinod Kumar S | 71cba68 | 2016-02-25 15:52:16 +0530 | [diff] [blame] | 226 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 227 | * @param moduleName module name |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 228 | */ |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 229 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 230 | public void setName(String moduleName) { |
| 231 | name = moduleName; |
| 232 | } |
| 233 | |
| 234 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 235 | * Returns the contact details of the module owner. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 236 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 237 | * @return the contact details of YANG owner |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 238 | */ |
| 239 | public String getContact() { |
| 240 | return contact; |
| 241 | } |
| 242 | |
| 243 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 244 | * Sets the contact details of the module owner. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 245 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 246 | * @param contact the contact details of YANG owner |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 247 | */ |
| 248 | public void setContact(String contact) { |
| 249 | this.contact = contact; |
| 250 | } |
| 251 | |
| 252 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 253 | * Returns the description of module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 254 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 255 | * @return the description of YANG module |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 256 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 257 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 258 | public String getDescription() { |
| 259 | return description; |
| 260 | } |
| 261 | |
| 262 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 263 | * Sets the description of module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 264 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 265 | * @param description set the description of YANG module |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 266 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 267 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 268 | public void setDescription(String description) { |
| 269 | this.description = description; |
| 270 | } |
| 271 | |
| 272 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 273 | * Returns the list of imported modules. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 274 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 275 | * @return the list of imported modules |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 276 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 277 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 278 | public List<YangImport> getImportList() { |
| 279 | return importList; |
| 280 | } |
| 281 | |
| 282 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 283 | * Adds the imported module information to the import list. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 284 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 285 | * @param importedModule module being imported |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 286 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 287 | @Override |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 288 | public void addToImportList(YangImport importedModule) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 289 | getImportList().add(importedModule); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 290 | } |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 291 | |
Gaurav Agrawal | d9d6cc8 | 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 | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 298 | * Returns the list of included sub modules. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 299 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 300 | * @return the included list of sub modules |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 301 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 302 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 303 | public List<YangInclude> getIncludeList() { |
| 304 | return includeList; |
| 305 | } |
| 306 | |
| 307 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 308 | * Adds the included sub module information to the include list. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 309 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 310 | * @param includeModule submodule being included |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 311 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 312 | @Override |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 313 | public void addToIncludeList(YangInclude includeModule) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 314 | getIncludeList().add(includeModule); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public void setIncludeList(List<YangInclude> includeList) { |
| 319 | this.includeList = includeList; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 320 | } |
| 321 | |
| 322 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 323 | * Returns the list of leaves in module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 324 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 325 | * @return the list of leaves |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 326 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 327 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 328 | public List<YangLeaf> getListOfLeaf() { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 329 | return listOfLeaf; |
| 330 | } |
| 331 | |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 332 | @Override |
| 333 | public void setListOfLeaf(List<YangLeaf> leafsList) { |
| 334 | listOfLeaf = leafsList; |
| 335 | } |
| 336 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 337 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 338 | * Adds a leaf in module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 339 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 340 | * @param leaf the leaf to be added |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 341 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 342 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 343 | public void addLeaf(YangLeaf leaf) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 344 | getListOfLeaf().add(leaf); |
| 345 | } |
| 346 | |
| 347 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 348 | * Returns the list of leaf-list from module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 349 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 350 | * @return the list of leaf-list |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 351 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 352 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 353 | public List<YangLeafList> getListOfLeafList() { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 354 | return listOfLeafList; |
| 355 | } |
| 356 | |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 357 | @Override |
| 358 | public void setListOfLeafList(List<YangLeafList> listOfLeafList) { |
| 359 | this.listOfLeafList = listOfLeafList; |
| 360 | } |
| 361 | |
| 362 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 363 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 364 | * Adds a leaf-list in module. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 365 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 366 | * @param leafList the leaf-list to be added |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 367 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 368 | @Override |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 369 | public void addLeafList(YangLeafList leafList) { |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 370 | getListOfLeafList().add(leafList); |
| 371 | } |
| 372 | |
| 373 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 374 | * Returns the name space of module elements. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 375 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 376 | * @return the nameSpace |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 377 | */ |
| 378 | public YangNameSpace getNameSpace() { |
| 379 | return nameSpace; |
| 380 | } |
| 381 | |
| 382 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 383 | * Sets the name space of module elements. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 384 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 385 | * @param nameSpace the nameSpace to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 386 | */ |
| 387 | public void setNameSpace(YangNameSpace nameSpace) { |
| 388 | this.nameSpace = nameSpace; |
| 389 | } |
| 390 | |
| 391 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 392 | * Returns the modules organization. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 393 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 394 | * @return the organization |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 395 | */ |
| 396 | public String getOrganization() { |
| 397 | return organization; |
| 398 | } |
| 399 | |
| 400 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 401 | * Sets the modules organization. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 402 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 403 | * @param org the organization to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 404 | */ |
| 405 | public void setOrganization(String org) { |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 406 | organization = org; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 407 | } |
| 408 | |
| 409 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 410 | * Returns the prefix. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 411 | * |
| 412 | * @return the prefix |
| 413 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 414 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 415 | public String getPrefix() { |
| 416 | return prefix; |
| 417 | } |
| 418 | |
| 419 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 420 | * Sets the prefix. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 421 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 422 | * @param prefix the prefix to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 423 | */ |
Bharat saraswal | cad0e65 | 2016-05-26 23:48:38 +0530 | [diff] [blame] | 424 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 425 | public void setPrefix(String prefix) { |
| 426 | this.prefix = prefix; |
| 427 | } |
| 428 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 429 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 430 | public void resolveSelfFileLinking(ResolvableType type) |
| 431 | throws DataModelException { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 432 | // Get the list to be resolved. |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 433 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 434 | // Resolve linking for a resolution list. |
| 435 | resolveLinkingForResolutionList(resolutionList, this); |
| 436 | } |
| 437 | |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 438 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 439 | public void resolveInterFileLinking(ResolvableType type) |
| 440 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 441 | // Get the list to be resolved. |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 442 | List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList(type); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 443 | // Resolve linking for a resolution list. |
| 444 | linkInterFileReferences(resolutionList, this); |
| 445 | } |
| 446 | |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 447 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 448 | * Returns the textual reference. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 449 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 450 | * @return the reference |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 451 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 452 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 453 | public String getReference() { |
| 454 | return reference; |
| 455 | } |
| 456 | |
| 457 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 458 | * Sets the textual reference. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 459 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 460 | * @param reference the reference to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 461 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 462 | @Override |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 463 | public void setReference(String reference) { |
| 464 | this.reference = reference; |
| 465 | } |
| 466 | |
| 467 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 468 | * Returns the revision. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 469 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 470 | * @return the revision |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 471 | */ |
| 472 | public YangRevision getRevision() { |
| 473 | return revision; |
| 474 | } |
| 475 | |
| 476 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 477 | * Sets the revision. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 478 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 479 | * @param revision the revision to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 480 | */ |
| 481 | public void setRevision(YangRevision revision) { |
| 482 | this.revision = revision; |
| 483 | } |
| 484 | |
| 485 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 486 | * Returns the version. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 487 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 488 | * @return the version |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 489 | */ |
| 490 | public byte getVersion() { |
| 491 | return version; |
| 492 | } |
| 493 | |
| 494 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 495 | * Sets the version. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 496 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 497 | * @param version the version to set |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 498 | */ |
| 499 | public void setVersion(byte version) { |
| 500 | this.version = version; |
| 501 | } |
| 502 | |
| 503 | /** |
| 504 | * Returns the type of the parsed data. |
| 505 | * |
Bharat saraswal | 2f00b4b | 2016-03-04 20:08:09 +0530 | [diff] [blame] | 506 | * @return returns MODULE_DATA |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 507 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 508 | @Override |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 509 | public YangConstructType getYangConstructType() { |
| 510 | return YangConstructType.MODULE_DATA; |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 511 | } |
| 512 | |
| 513 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 514 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 515 | * |
| 516 | * @throws DataModelException a violation of data model rules |
| 517 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 518 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 519 | public void validateDataOnEntry() |
| 520 | throws DataModelException { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 521 | /* |
| 522 | * Module is root in the data model tree, hence there is no entry |
| 523 | * validation |
| 524 | */ |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 525 | } |
| 526 | |
| 527 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 528 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 529 | * |
| 530 | * @throws DataModelException a violation of data model rules |
| 531 | */ |
Bharat saraswal | 870c56f | 2016-02-20 21:57:16 +0530 | [diff] [blame] | 532 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 533 | public void validateDataOnExit() |
| 534 | throws DataModelException { |
Vinod Kumar S | 0c330cd | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 535 | /* |
| 536 | * TODO: perform symbol linking for the imported or included YANG info. |
| 537 | * TODO: perform symbol resolution for referred YANG entities. |
| 538 | */ |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 539 | } |
Vinod Kumar S | 67e7be6 | 2016-02-11 20:13:28 +0530 | [diff] [blame] | 540 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 541 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 542 | public void detectCollidingChild(String identifierName, YangConstructType dataType) |
| 543 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 544 | // Asks helper to detect colliding child. |
| 545 | detectCollidingChildUtil(identifierName, dataType, this); |
| 546 | } |
| 547 | |
| 548 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 549 | public void detectSelfCollision(String identifierName, YangConstructType dataType) |
| 550 | throws DataModelException { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 551 | // Not required as module doesn't have any parent. |
| 552 | } |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 553 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 554 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 555 | public List<YangResolutionInfo> getUnresolvedResolutionList(ResolvableType type) { |
| 556 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 557 | return derivedTypeResolutionList; |
| 558 | } else { |
| 559 | return usesResolutionList; |
| 560 | } |
| 561 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 565 | public void addToResolutionList(YangResolutionInfo resolutionInfo, |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 566 | ResolvableType type) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 567 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 568 | derivedTypeResolutionList.add(resolutionInfo); |
| 569 | } else if (type == ResolvableType.YANG_USES) { |
| 570 | usesResolutionList.add(resolutionInfo); |
| 571 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | @Override |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 575 | public void setResolutionList(List<YangResolutionInfo> resolutionList, |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 576 | ResolvableType type) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 577 | if (type == ResolvableType.YANG_DERIVED_DATA_TYPE) { |
| 578 | derivedTypeResolutionList = resolutionList; |
| 579 | } else if (type == ResolvableType.YANG_USES) { |
| 580 | usesResolutionList = resolutionList; |
| 581 | } |
| 582 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 583 | } |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 584 | |
| 585 | @Override |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 586 | public void addReferencesToImportList(Set<YangNode> yangNodeSet) |
| 587 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 588 | Iterator<YangImport> importInfoIterator = getImportList().iterator(); |
| 589 | // Run through the imported list to add references. |
| 590 | while (importInfoIterator.hasNext()) { |
| 591 | YangImport yangImport = importInfoIterator.next(); |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 592 | yangImport.addReferenceToImport(yangNodeSet); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 593 | } |
| 594 | } |
| 595 | |
| 596 | @Override |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 597 | public void addReferencesToIncludeList(Set<YangNode> yangNodeSet) |
| 598 | throws DataModelException { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 599 | Iterator<YangInclude> includeInfoIterator = getIncludeList().iterator(); |
| 600 | // Run through the included list to add references. |
| 601 | while (includeInfoIterator.hasNext()) { |
| 602 | YangInclude yangInclude = includeInfoIterator.next(); |
| 603 | YangSubModule subModule = null; |
| 604 | try { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 605 | subModule = yangInclude.addReferenceToInclude(yangNodeSet); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 606 | } catch (DataModelException e) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 607 | throw e; |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 608 | } |
| 609 | // Check if the referred sub-modules parent is self |
| 610 | if (!(subModule.getBelongsTo().getModuleNode() == this)) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame^] | 611 | yangInclude.reportIncludeError(); |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 612 | } |
| 613 | } |
| 614 | } |
Vinod Kumar S | 1ede5ab | 2016-02-09 20:14:53 +0530 | [diff] [blame] | 615 | } |