Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +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 | |
| 17 | package org.onosproject.yangutils.datamodel.utils; |
| 18 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 19 | import java.util.List; |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 20 | import java.util.Set; |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 21 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 22 | import org.onosproject.yangutils.datamodel.CollisionDetector; |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 23 | import org.onosproject.yangutils.datamodel.ResolvableType; |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 24 | import org.onosproject.yangutils.datamodel.YangIfFeature; |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 25 | import org.onosproject.yangutils.datamodel.YangBase; |
| 26 | import org.onosproject.yangutils.datamodel.YangIdentityRef; |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 27 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| 28 | import org.onosproject.yangutils.datamodel.YangLeafList; |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 29 | import org.onosproject.yangutils.datamodel.YangLeafRef; |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 30 | import org.onosproject.yangutils.datamodel.YangLeavesHolder; |
| 31 | import org.onosproject.yangutils.datamodel.YangNode; |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 32 | import org.onosproject.yangutils.datamodel.YangReferenceResolver; |
| 33 | import org.onosproject.yangutils.datamodel.YangResolutionInfo; |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 34 | import org.onosproject.yangutils.datamodel.YangRpc; |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 35 | import org.onosproject.yangutils.datamodel.YangType; |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 36 | import org.onosproject.yangutils.datamodel.YangUses; |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 37 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 38 | |
| 39 | /** |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 40 | * Represents utilities for data model tree. |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 41 | */ |
| 42 | public final class DataModelUtils { |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 43 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 44 | /** |
| 45 | * Creates a new data model tree utility. |
| 46 | */ |
| 47 | private DataModelUtils() { |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Detects the colliding identifier name in a given YANG node and its child. |
| 52 | * |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 53 | * @param identifierName name for which collision detection is to be checked |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 54 | * @param dataType type of YANG node asking for detecting collision |
| 55 | * @param node instance of calling node |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 56 | * @throws DataModelException a violation of data model rules |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 57 | */ |
| 58 | public static void detectCollidingChildUtil(String identifierName, YangConstructType dataType, YangNode node) |
| 59 | throws DataModelException { |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 60 | if (dataType == YangConstructType.USES_DATA || dataType == YangConstructType.GROUPING_DATA) { |
| 61 | detectCollidingForUsesGrouping(identifierName, dataType, node); |
| 62 | } else { |
| 63 | if (node instanceof YangLeavesHolder) { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 64 | YangLeavesHolder leavesHolder = (YangLeavesHolder) node; |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 65 | detectCollidingLeaf(leavesHolder.getListOfLeaf(), identifierName); |
| 66 | detectCollidingLeafList(leavesHolder.getListOfLeafList(), identifierName); |
| 67 | } |
| 68 | node = node.getChild(); |
| 69 | while (node != null) { |
| 70 | Parsable parsable = (Parsable) node; |
| 71 | if (node instanceof CollisionDetector |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 72 | && parsable.getYangConstructType() != YangConstructType.USES_DATA |
| 73 | && parsable.getYangConstructType() != YangConstructType.GROUPING_DATA) { |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 74 | ((CollisionDetector) node).detectSelfCollision(identifierName, dataType); |
| 75 | } |
| 76 | node = node.getNextSibling(); |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 77 | } |
| 78 | } |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Detects colliding of uses and grouping only with uses and grouping respectively. |
| 83 | * |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 84 | * @param identifierName name for which collision detection is to be checked |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 85 | * @param dataType type of YANG node asking for detecting collision |
| 86 | * @param node node instance of calling node |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 87 | * @throws DataModelException a violation of data model rules |
| 88 | */ |
| 89 | public static void detectCollidingForUsesGrouping(String identifierName, YangConstructType dataType, YangNode node) |
| 90 | throws DataModelException { |
| 91 | |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 92 | node = node.getChild(); |
Vinod Kumar S | 3804650 | 2016-03-23 15:30:27 +0530 | [diff] [blame] | 93 | while (node != null) { |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 94 | Parsable parsable = (Parsable) node; |
| 95 | if (node instanceof CollisionDetector |
Bharat saraswal | 33dfa01 | 2016-05-17 19:59:16 +0530 | [diff] [blame] | 96 | && parsable.getYangConstructType() == dataType) { |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 97 | ((CollisionDetector) node).detectSelfCollision(identifierName, dataType); |
| 98 | } |
| 99 | node = node.getNextSibling(); |
| 100 | } |
| 101 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 102 | |
| 103 | /** |
| 104 | * Detects the colliding identifier name in a given leaf node. |
| 105 | * |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 106 | * @param listOfLeaf List of leaves to detect collision |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 107 | * @param identifierName name for which collision detection is to be checked |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 108 | * @throws DataModelException a violation of data model rules |
| 109 | */ |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 110 | private static void detectCollidingLeaf(List<YangLeaf> listOfLeaf, String identifierName) |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 111 | throws DataModelException { |
| 112 | |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 113 | if (listOfLeaf == null) { |
| 114 | return; |
| 115 | } |
| 116 | for (YangLeaf leaf : listOfLeaf) { |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 117 | if (leaf.getName().equals(identifierName)) { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 118 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \"" |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 119 | + leaf.getName() + "\""); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 120 | } |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Detects the colliding identifier name in a given leaf-list node. |
| 126 | * |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 127 | * @param listOfLeafList list of leaf-lists to detect collision |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 128 | * @param identifierName name for which collision detection is to be checked |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 129 | * @throws DataModelException a violation of data model rules |
| 130 | */ |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 131 | private static void detectCollidingLeafList(List<YangLeafList> listOfLeafList, String identifierName) |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 132 | throws DataModelException { |
| 133 | |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 134 | if (listOfLeafList == null) { |
| 135 | return; |
| 136 | } |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 137 | for (YangLeafList leafList : listOfLeafList) { |
| 138 | if (leafList.getName().equals(identifierName)) { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 139 | throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " + |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 140 | "list \"" + leafList.getName() + "\""); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Add a resolution information. |
| 147 | * |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 148 | * @param resolutionInfo information about the YANG construct which has to be resolved |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 149 | * @throws DataModelException a violation of data model rules |
| 150 | */ |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 151 | public static void addResolutionInfo(YangResolutionInfo resolutionInfo) |
| 152 | throws DataModelException { |
| 153 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 154 | /* get the module node to add maintain the list of nested reference */ |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 155 | YangNode curNode = resolutionInfo.getEntityToResolveInfo() |
| 156 | .getHolderOfEntityToResolve(); |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 157 | while (!(curNode instanceof YangReferenceResolver)) { |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 158 | curNode = curNode.getParent(); |
| 159 | if (curNode == null) { |
| 160 | throw new DataModelException("Internal datamodel error: Datamodel tree is not correct"); |
| 161 | } |
| 162 | } |
Vinod Kumar S | e4b9b0c | 2016-04-30 21:09:15 +0530 | [diff] [blame] | 163 | YangReferenceResolver resolutionNode = (YangReferenceResolver) curNode; |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 164 | |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 165 | if (resolutionInfo.getEntityToResolveInfo() |
| 166 | .getEntityToResolve() instanceof YangType) { |
| 167 | resolutionNode.addToResolutionList(resolutionInfo, |
| 168 | ResolvableType.YANG_DERIVED_DATA_TYPE); |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 169 | } else if (resolutionInfo.getEntityToResolveInfo() |
| 170 | .getEntityToResolve() instanceof YangUses) { |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 171 | resolutionNode.addToResolutionList(resolutionInfo, |
| 172 | ResolvableType.YANG_USES); |
Vidyashree Rama | deac28b | 2016-06-20 15:12:43 +0530 | [diff] [blame] | 173 | } else if (resolutionInfo.getEntityToResolveInfo() |
| 174 | .getEntityToResolve() instanceof YangIfFeature) { |
| 175 | resolutionNode.addToResolutionList(resolutionInfo, |
| 176 | ResolvableType.YANG_IF_FEATURE); |
janani b | e18b534 | 2016-07-13 21:06:41 +0530 | [diff] [blame] | 177 | } else if (resolutionInfo.getEntityToResolveInfo() |
| 178 | .getEntityToResolve() instanceof YangLeafRef) { |
| 179 | resolutionNode.addToResolutionList(resolutionInfo, |
| 180 | ResolvableType.YANG_LEAFREF); |
Shankara-Huawei | df7b9ca | 2016-07-14 11:35:34 +0530 | [diff] [blame] | 181 | } else if (resolutionInfo.getEntityToResolveInfo().getEntityToResolve() instanceof YangBase) { |
| 182 | resolutionNode.addToResolutionList(resolutionInfo, ResolvableType.YANG_BASE); |
| 183 | } else if (resolutionInfo.getEntityToResolveInfo().getEntityToResolve() instanceof YangIdentityRef) { |
| 184 | resolutionNode.addToResolutionList(resolutionInfo, ResolvableType.YANG_IDENTITYREF); |
VinodKumarS-Huawei | 2ee9e7e | 2016-06-01 14:30:22 +0530 | [diff] [blame] | 185 | } |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 186 | } |
| 187 | |
janani b | 4e53f9b | 2016-04-26 18:49:20 +0530 | [diff] [blame] | 188 | /** |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 189 | * Resolve linking for a resolution list. |
| 190 | * |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 191 | * @param resolutionList resolution list for which linking to be done |
Vinod Kumar S | d4deb06 | 2016-04-15 18:08:57 +0530 | [diff] [blame] | 192 | * @param dataModelRootNode module/sub-module node |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 193 | * @throws DataModelException a violation of data model rules |
| 194 | */ |
| 195 | public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList, |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 196 | YangReferenceResolver dataModelRootNode) |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 197 | throws DataModelException { |
Bharat saraswal | d9822e9 | 2016-04-05 15:13:44 +0530 | [diff] [blame] | 198 | |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 199 | for (YangResolutionInfo resolutionInfo : resolutionList) { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 200 | resolutionInfo.resolveLinkingForResolutionInfo(dataModelRootNode); |
| 201 | } |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Links type/uses referring to typedef/uses of inter YANG file. |
| 206 | * |
| 207 | * @param resolutionList resolution list for which linking to be done |
| 208 | * @param dataModelRootNode module/sub-module node |
| 209 | * @throws DataModelException a violation of data model rules |
| 210 | */ |
| 211 | public static void linkInterFileReferences(List<YangResolutionInfo> resolutionList, |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 212 | YangReferenceResolver dataModelRootNode) |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 213 | throws DataModelException { |
| 214 | /* |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 215 | * Run through the resolution list, find type/uses referring to inter |
| 216 | * file typedef/grouping, ask for linking. |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 217 | */ |
| 218 | for (YangResolutionInfo resolutionInfo : resolutionList) { |
| 219 | resolutionInfo.linkInterFile(dataModelRootNode); |
Gaurav Agrawal | d9d6cc8 | 2016-03-29 02:17:23 +0530 | [diff] [blame] | 220 | } |
| 221 | } |
VinodKumarS-Huawei | cb3a1f5 | 2016-05-10 17:58:57 +0530 | [diff] [blame] | 222 | |
| 223 | /** |
| 224 | * Checks if there is any rpc defined in the module or sub-module. |
| 225 | * |
| 226 | * @param rootNode root node of the data model |
| 227 | * @return status of rpc's existence |
| 228 | */ |
| 229 | public static boolean isRpcChildNodePresent(YangNode rootNode) { |
| 230 | YangNode childNode = rootNode.getChild(); |
| 231 | while (childNode != null) { |
| 232 | if (childNode instanceof YangRpc) { |
| 233 | return true; |
| 234 | } |
| 235 | childNode = childNode.getNextSibling(); |
| 236 | } |
| 237 | return false; |
| 238 | } |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 239 | |
| 240 | /** |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 241 | * Returns referred node in a given set. |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 242 | * |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 243 | * @param yangNodeSet YANG node set |
| 244 | * @param refNodeName name of the node which is referred |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 245 | * @return referred node's reference |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 246 | */ |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 247 | public static YangNode findReferredNode(Set<YangNode> yangNodeSet, String refNodeName) { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 248 | /* |
| 249 | * Run through the YANG files to see which YANG file matches the |
| 250 | * referred node name. |
| 251 | */ |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 252 | for (YangNode yangNode : yangNodeSet) { |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 253 | if (yangNode.getName().equals(refNodeName)) { |
Gaurav Agrawal | 95b416c | 2016-06-07 14:00:26 +0530 | [diff] [blame] | 254 | return yangNode; |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 255 | } |
| 256 | } |
Gaurav Agrawal | 0d43bb5 | 2016-05-17 18:06:38 +0530 | [diff] [blame] | 257 | return null; |
Vidyashree Rama | 1db1556 | 2016-05-17 16:16:15 +0530 | [diff] [blame] | 258 | } |
Bharat saraswal | 96dfef0 | 2016-06-16 00:29:12 +0530 | [diff] [blame] | 259 | |
| 260 | /** |
| 261 | * Returns the contained data model parent node. |
| 262 | * |
| 263 | * @param currentNode current node which parent contained node is required |
| 264 | * @return parent node in which the current node is an attribute |
| 265 | */ |
| 266 | public static YangNode getParentNodeInGenCode(YangNode currentNode) { |
| 267 | |
| 268 | /* |
| 269 | * TODO: recursive parent lookup to support choice/augment/uses. TODO: |
| 270 | * need to check if this needs to be updated for |
| 271 | * choice/case/augment/grouping |
| 272 | */ |
| 273 | return currentNode.getParent(); |
| 274 | } |
Gaurav Agrawal | 8e8770a | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 275 | } |