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