blob: 6f0fe424b50401c653e81c4be71fbd40d151ee9a [file] [log] [blame]
Vinod Kumar S9f26ae52016-03-23 15:30:27 +05301/*
Brian O'Connor0f7908b2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S9f26ae52016-03-23 15:30:27 +05303 *
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
17package org.onosproject.yangutils.translator.tojava;
18
19import java.io.IOException;
Bharat saraswal8beac342016-08-04 02:00:03 +053020import java.util.ArrayList;
21import java.util.List;
22
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +053023import org.onosproject.yangutils.datamodel.TraversalType;
Bharat saraswal8beac342016-08-04 02:00:03 +053024import org.onosproject.yangutils.datamodel.YangAugment;
25import org.onosproject.yangutils.datamodel.YangCase;
26import org.onosproject.yangutils.datamodel.YangChoice;
Bharat saraswalaab24b92016-08-02 18:43:16 +053027import org.onosproject.yangutils.datamodel.YangInput;
Bharat saraswale50edca2016-08-05 01:58:25 +053028import org.onosproject.yangutils.datamodel.YangLeaf;
29import org.onosproject.yangutils.datamodel.YangLeafList;
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053030import org.onosproject.yangutils.datamodel.YangNode;
Bharat saraswalaab24b92016-08-02 18:43:16 +053031import org.onosproject.yangutils.datamodel.YangNodeType;
32import org.onosproject.yangutils.datamodel.YangOutput;
Bharat saraswal8beac342016-08-04 02:00:03 +053033import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswale50edca2016-08-05 01:58:25 +053034import org.onosproject.yangutils.utils.io.YangPluginConfig;
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +053035import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException;
Bharat saraswal780eca32016-04-05 12:45:45 +053036import org.onosproject.yangutils.translator.exception.TranslatorException;
janani bb3be1332016-08-03 16:40:01 +053037
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +053038import static org.onosproject.yangutils.datamodel.TraversalType.CHILD;
39import static org.onosproject.yangutils.datamodel.TraversalType.PARENT;
40import static org.onosproject.yangutils.datamodel.TraversalType.ROOT;
41import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING;
Bharat saraswal8beac342016-08-04 02:00:03 +053042import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
43import static org.onosproject.yangutils.translator.tojava.YangDataModelFactory.getYangCaseNode;
44import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.getAugmentClassName;
45import static org.onosproject.yangutils.utils.UtilConstants.CASE;
46import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
Bharat saraswal64e7e232016-07-14 23:33:55 +053047import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053048
49/**
Vidyashree Rama02f115f2016-04-18 12:29:39 +053050 * Representation of java code generator based on application schema.
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053051 */
52public final class JavaCodeGeneratorUtil {
53
54 /**
Bharat saraswal780eca32016-04-05 12:45:45 +053055 * Current YANG node.
56 */
57 private static YangNode curNode;
58
59 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +053060 * Root node.
61 */
62 private static YangNode rootNode;
63
Bharat saraswale50edca2016-08-05 01:58:25 +053064 private static int calls = 0;
65
Bharat saraswal64e7e232016-07-14 23:33:55 +053066 /**
Vinod Kumar S79a374b2016-04-30 21:09:15 +053067 * Creates a java code generator utility object.
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053068 */
69 private JavaCodeGeneratorUtil() {
70 }
71
72 /**
Bharat saraswal780eca32016-04-05 12:45:45 +053073 * Returns current YANG node.
74 *
75 * @return current YANG node
76 */
77 public static YangNode getCurNode() {
78 return curNode;
79 }
80
81 /**
82 * Sets current YANG node.
83 *
84 * @param node current YANG node
85 */
Bharat saraswal780eca32016-04-05 12:45:45 +053086 public static void setCurNode(YangNode node) {
87 curNode = node;
88 }
89
90 /**
Bharat saraswal63f26fb2016-04-05 15:13:44 +053091 * Generates Java code files corresponding to the YANG schema.
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053092 *
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +053093 * @param rootNode root node of the data model tree
janani b1c6acc42016-04-15 16:18:30 +053094 * @param yangPlugin YANG plugin config
Bharat saraswal64e7e232016-07-14 23:33:55 +053095 * @throws TranslatorException when fails to generate java code file the current node
96 * @throws IOException when fails to do IO operations
Vinod Kumar S9f26ae52016-03-23 15:30:27 +053097 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +053098 public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin)
Bharat saraswal64e7e232016-07-14 23:33:55 +053099 throws TranslatorException, IOException {
Bharat saraswal780eca32016-04-05 12:45:45 +0530100
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530101 YangNode codeGenNode = rootNode;
Bharat saraswal64e7e232016-07-14 23:33:55 +0530102 setRootNode(rootNode);
Bharat saraswal780eca32016-04-05 12:45:45 +0530103 TraversalType curTraversal = ROOT;
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530104
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530105 while (codeGenNode != null) {
Bharat saraswal8beac342016-08-04 02:00:03 +0530106 if (codeGenNode instanceof YangAugment) {
107 if (((YangAugment) codeGenNode).getAugmentedNode() instanceof YangChoice) {
108 addCaseNodeToChoiceTarget((YangAugment) codeGenNode);
109 }
110 }
Bharat saraswal780eca32016-04-05 12:45:45 +0530111 if (curTraversal != PARENT) {
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530112 if (!(codeGenNode instanceof JavaCodeGenerator)) {
113 throw new TranslatorException("Unsupported node to generate code");
114 }
Bharat saraswal5cd9e9c2016-05-26 23:48:38 +0530115 setCurNode(codeGenNode);
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530116 try {
117 generateCodeEntry(codeGenNode, yangPlugin);
Vidyashree Ramaa89bdd32016-07-08 20:45:41 +0530118 } catch (InvalidNodeForTranslatorException e) {
119 if (codeGenNode.getNextSibling() != null) {
120 curTraversal = SIBILING;
121 codeGenNode = codeGenNode.getNextSibling();
122 } else {
123 curTraversal = PARENT;
124 codeGenNode = codeGenNode.getParent();
125 }
126 continue;
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530127 } catch (Exception e) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530128 close(codeGenNode, yangPlugin);
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530129 throw new TranslatorException(e.getMessage());
130 }
131
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530132 }
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530133 if (curTraversal != PARENT && codeGenNode.getChild() != null) {
Bharat saraswal780eca32016-04-05 12:45:45 +0530134 curTraversal = CHILD;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530135 codeGenNode = codeGenNode.getChild();
136 } else if (codeGenNode.getNextSibling() != null) {
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530137 try {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530138 generateCodeExit(codeGenNode, yangPlugin);
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530139 } catch (Exception e) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530140 close(codeGenNode, yangPlugin);
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530141 throw new TranslatorException(e.getMessage());
142 }
Bharat saraswal780eca32016-04-05 12:45:45 +0530143 curTraversal = SIBILING;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530144 codeGenNode = codeGenNode.getNextSibling();
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530145 } else {
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530146 try {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530147 generateCodeExit(codeGenNode, yangPlugin);
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530148 } catch (Exception e) {
Bharat saraswale50edca2016-08-05 01:58:25 +0530149 close(codeGenNode, yangPlugin);
150 throw new TranslatorException(e.getMessage());
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530151 }
Bharat saraswal780eca32016-04-05 12:45:45 +0530152 curTraversal = PARENT;
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530153 codeGenNode = codeGenNode.getParent();
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530154 }
155 }
156 }
157
158 /**
159 * Generates the current nodes code snippet.
160 *
Bharat saraswal64e7e232016-07-14 23:33:55 +0530161 * @param codeGenNode current data model node for which the code needs to be generated
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530162 * @param yangPlugin YANG plugin config
Bharat saraswal64e7e232016-07-14 23:33:55 +0530163 * @throws TranslatorException when fails to generate java code file the current node
164 * @throws IOException when fails to do IO operations
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530165 */
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530166 private static void generateCodeEntry(YangNode codeGenNode, YangPluginConfig yangPlugin)
Bharat saraswal64e7e232016-07-14 23:33:55 +0530167 throws TranslatorException, IOException {
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530168
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530169 if (codeGenNode instanceof JavaCodeGenerator) {
170 ((JavaCodeGenerator) codeGenNode).generateCodeEntry(yangPlugin);
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530171 } else {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530172 close(codeGenNode, yangPlugin);
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530173 throw new TranslatorException(
Bharat saraswal780eca32016-04-05 12:45:45 +0530174 "Generated data model node cannot be translated to target language code");
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530175 }
176 }
177
178 /**
179 * Generates the current nodes code target code from the snippet.
180 *
Bharat saraswal64e7e232016-07-14 23:33:55 +0530181 * @param codeGenNode current data model node for which the code needs to be generated
182 * @param pluginConfig plugin configurations
183 * @throws TranslatorException when fails to generate java code file the current node
184 * @throws IOException when fails to do IO operations
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530185 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530186 private static void generateCodeExit(YangNode codeGenNode, YangPluginConfig pluginConfig)
187 throws TranslatorException, IOException {
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530188
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530189 if (codeGenNode instanceof JavaCodeGenerator) {
190 ((JavaCodeGenerator) codeGenNode).generateCodeExit();
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530191 } else {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530192 close(codeGenNode, pluginConfig);
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530193 throw new TranslatorException(
Bharat saraswal780eca32016-04-05 12:45:45 +0530194 "Generated data model node cannot be translated to target language code");
195 }
196 }
197
198 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +0530199 * Free other YANG nodes of data-model tree when error occurs while file generation of current node.
Bharat saraswal780eca32016-04-05 12:45:45 +0530200 */
Bharat saraswal4aaab4d2016-05-17 14:19:38 +0530201 private static void freeRestResources() {
Bharat saraswal780eca32016-04-05 12:45:45 +0530202
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530203 YangNode freedNode = getCurNode();
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530204 if (getCurNode() != null) {
205 YangNode tempNode = freedNode;
206 TraversalType curTraversal = ROOT;
Bharat saraswal780eca32016-04-05 12:45:45 +0530207
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530208 while (freedNode != tempNode.getParent()) {
Bharat saraswal780eca32016-04-05 12:45:45 +0530209
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530210 if (curTraversal != PARENT && freedNode.getChild() != null) {
211 curTraversal = CHILD;
212 freedNode = freedNode.getChild();
213 } else if (freedNode.getNextSibling() != null) {
214 curTraversal = SIBILING;
215 if (freedNode != tempNode) {
216 free(freedNode);
217 }
218 freedNode = freedNode.getNextSibling();
219 } else {
220 curTraversal = PARENT;
221 if (freedNode != tempNode) {
222 free(freedNode);
223 }
224 freedNode = freedNode.getParent();
Bharat saraswal780eca32016-04-05 12:45:45 +0530225 }
Bharat saraswal780eca32016-04-05 12:45:45 +0530226 }
227 }
228 }
229
230 /**
231 * Free the current node.
232 *
233 * @param node YANG node
Bharat saraswal780eca32016-04-05 12:45:45 +0530234 */
Vidyashree Rama02f115f2016-04-18 12:29:39 +0530235 private static void free(YangNode node) {
Bharat saraswal780eca32016-04-05 12:45:45 +0530236
237 YangNode parent = node.getParent();
238 parent.setChild(null);
Bharat saraswal63f26fb2016-04-05 15:13:44 +0530239
Bharat saraswal780eca32016-04-05 12:45:45 +0530240 if (node.getNextSibling() != null) {
241 parent.setChild(node.getNextSibling());
242 } else if (node.getPreviousSibling() != null) {
243 parent.setChild(node.getPreviousSibling());
244 }
245 node = null;
246 }
247
248 /**
249 * Delete Java code files corresponding to the YANG schema.
250 *
Bharat saraswal64e7e232016-07-14 23:33:55 +0530251 * @param rootNode root node of data-model tree
252 * @param yangPluginConfig plugin configurations
VinodKumarS-Huaweid81eccb2016-06-01 14:30:22 +0530253 * @throws IOException when fails to delete java code file the current node
Bharat saraswal780eca32016-04-05 12:45:45 +0530254 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530255 public static void translatorErrorHandler(YangNode rootNode, YangPluginConfig yangPluginConfig)
Bharat saraswal4aaab4d2016-05-17 14:19:38 +0530256 throws IOException {
Bharat saraswal780eca32016-04-05 12:45:45 +0530257
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530258 if (rootNode != null) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530259 //Free other resources where translator has failed.
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530260 freeRestResources();
Bharat saraswal780eca32016-04-05 12:45:45 +0530261
Bharat saraswal64e7e232016-07-14 23:33:55 +0530262 // Start removing all open files.
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530263 YangNode tempNode = rootNode;
264 setCurNode(tempNode.getChild());
265 TraversalType curTraversal = ROOT;
Bharat saraswal780eca32016-04-05 12:45:45 +0530266
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530267 while (tempNode != null) {
Bharat saraswal780eca32016-04-05 12:45:45 +0530268
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530269 if (curTraversal != PARENT) {
Bharat saraswal64e7e232016-07-14 23:33:55 +0530270 close(tempNode, yangPluginConfig);
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530271 }
272 if (curTraversal != PARENT && tempNode.getChild() != null) {
273 curTraversal = CHILD;
274 tempNode = tempNode.getChild();
275 } else if (tempNode.getNextSibling() != null) {
276 curTraversal = SIBILING;
277 tempNode = tempNode.getNextSibling();
278 } else {
279 curTraversal = PARENT;
280 tempNode = tempNode.getParent();
281 }
Bharat saraswal780eca32016-04-05 12:45:45 +0530282 }
Bharat saraswal715d3fc2016-05-17 19:59:16 +0530283
284 freeRestResources();
Bharat saraswal780eca32016-04-05 12:45:45 +0530285 }
Bharat saraswal780eca32016-04-05 12:45:45 +0530286 }
287
288 /**
Bharat saraswal64e7e232016-07-14 23:33:55 +0530289 * Closes all the current open file handles of node and delete all generated files.
Bharat saraswal780eca32016-04-05 12:45:45 +0530290 *
Bharat saraswal64e7e232016-07-14 23:33:55 +0530291 * @param node current YANG node
292 * @param yangPlugin plugin configurations
Bharat saraswal780eca32016-04-05 12:45:45 +0530293 * @throws IOException when fails to do IO operations
294 */
Bharat saraswal64e7e232016-07-14 23:33:55 +0530295 private static void close(YangNode node, YangPluginConfig yangPlugin)
Vinod Kumar S79a374b2016-04-30 21:09:15 +0530296 throws IOException {
Vidyashree Rama5daea742016-05-20 16:29:25 +0530297 if (node instanceof JavaCodeGenerator && ((TempJavaCodeFragmentFilesContainer) node)
298 .getTempJavaCodeFragmentFiles() != null) {
VinodKumarS-Huawei6266db32016-05-10 17:58:57 +0530299 ((TempJavaCodeFragmentFilesContainer) node).getTempJavaCodeFragmentFiles().freeTemporaryResources(true);
Bharat saraswal64e7e232016-07-14 23:33:55 +0530300 } else {
301
janani bb3be1332016-08-03 16:40:01 +0530302 if (getRootNode() != null) {
Bharat saraswale50edca2016-08-05 01:58:25 +0530303 JavaFileInfoTranslator javaFileInfo = ((JavaFileInfoContainer) getRootNode()).getJavaFileInfo();
janani bb3be1332016-08-03 16:40:01 +0530304 if (javaFileInfo != null) {
305 searchAndDeleteTempDir(javaFileInfo.getBaseCodeGenPath() +
306 javaFileInfo.getPackageFilePath());
307 } else {
Bharat saraswal8beac342016-08-04 02:00:03 +0530308 searchAndDeleteTempDir(yangPlugin.getCodeGenDir());
janani bb3be1332016-08-03 16:40:01 +0530309 }
Bharat saraswal64e7e232016-07-14 23:33:55 +0530310 }
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530311 }
312 }
Bharat saraswal64e7e232016-07-14 23:33:55 +0530313
314 /**
315 * Returns root node.
316 *
317 * @return root node
318 */
319 private static YangNode getRootNode() {
320 return rootNode;
321 }
322
323 /**
324 * Sets root node.
325 *
326 * @param rootNode root node
327 */
328 private static void setRootNode(YangNode rootNode) {
329 JavaCodeGeneratorUtil.rootNode = rootNode;
330 }
Bharat saraswalaab24b92016-08-02 18:43:16 +0530331
332 /**
333 * Searches child node in data model tree.
334 *
335 * @param parentNode parent node
336 * @param nodeType node type
337 * @param nodeName node name
338 * @return child node
339 */
340 public static YangNode searchYangNode(YangNode parentNode, YangNodeType nodeType, String nodeName) {
341 YangNode child = parentNode.getChild();
342 TraversalType curTraversal = ROOT;
343 if (child == null) {
janani bb3be1332016-08-03 16:40:01 +0530344 throw new IllegalArgumentException("Given parent node does not contain any child nodes");
Bharat saraswalaab24b92016-08-02 18:43:16 +0530345 }
346
347 while (child != null) {
348 if (curTraversal != PARENT) {
349 if (child instanceof YangInput || child instanceof YangOutput) {
350 if (child.getNodeType().equals(nodeType)) {
351 return child;
352 }
353 } else if (child.getName().equals(nodeName) && child.getNodeType().equals(nodeType)) {
354 return child;
355 }
356 }
357 if (curTraversal != PARENT && child.getChild() != null) {
358 curTraversal = CHILD;
359 child = child.getChild();
360 } else if (child.getNextSibling() != null) {
361 curTraversal = SIBILING;
362 child = child.getNextSibling();
363 } else {
364 curTraversal = PARENT;
365 child = child.getParent();
366 }
367 }
368 return null;
369 }
Bharat saraswal8beac342016-08-04 02:00:03 +0530370
371 /**
372 * Adds a case node in augment when augmenting a choice node.
373 *
374 * @param augment augment node
375 */
376 private static void addCaseNodeToChoiceTarget(YangAugment augment) {
Bharat saraswale50edca2016-08-05 01:58:25 +0530377 calls++;
378 if (calls == 1) {
379 YangCase javaCase = getYangCaseNode(JAVA_GENERATION);
Bharat saraswal8beac342016-08-04 02:00:03 +0530380
Bharat saraswale50edca2016-08-05 01:58:25 +0530381 YangPluginConfig pluginConfig = new YangPluginConfig();
382 javaCase.setName(getAugmentClassName(augment, pluginConfig) + getCapitalCase(CASE));
Bharat saraswal8beac342016-08-04 02:00:03 +0530383
Bharat saraswale50edca2016-08-05 01:58:25 +0530384 if (augment.getListOfLeaf() != null) {
385 for (YangLeaf leaf : augment.getListOfLeaf()) {
386 javaCase.addLeaf(leaf);
387 }
388 augment.getListOfLeaf().clear();
Bharat saraswal8beac342016-08-04 02:00:03 +0530389 }
Bharat saraswale50edca2016-08-05 01:58:25 +0530390 if (augment.getListOfLeafList() != null) {
391 for (YangLeafList leafList : augment.getListOfLeafList()) {
392 javaCase.addLeafList(leafList);
393 }
394 augment.getListOfLeafList().clear();
395 }
396 YangNode child = augment.getChild();
397 List<YangNode> childNodes = new ArrayList<>();
398 while (child != null) {
399 child.setParent(javaCase);
400 childNodes.add(child);
401 child = child.getNextSibling();
402 }
403 augment.setChild(null);
404 try {
405 augment.addChild(javaCase);
406 for (YangNode node : childNodes) {
407 node.setNextSibling(null);
408 node.setPreviousSibling(null);
409 javaCase.addChild(node);
410 }
411 } catch (DataModelException e) {
412 throw new TranslatorException("Failed to add child nodes to case node of augment " + augment.getName());
413 }
Bharat saraswal8beac342016-08-04 02:00:03 +0530414 }
415 }
Vinod Kumar S9f26ae52016-03-23 15:30:27 +0530416}