Bharat saraswal
Committed by Gerrit Code Review

[ONOS-4583] Union defect fix.

Change-Id: Ic31866b9a1b7bd5d8209d5d22f4292ab9c79a118
Showing 36 changed files with 2338 additions and 617 deletions
...@@ -75,7 +75,7 @@ public class YangXpathLinker<T> { ...@@ -75,7 +75,7 @@ public class YangXpathLinker<T> {
75 * 75 *
76 * @return prefix resolver list 76 * @return prefix resolver list
77 */ 77 */
78 - public Map<YangAtomicPath, PrefixResolverType> getPrefixResolverTypes() { 78 + private Map<YangAtomicPath, PrefixResolverType> getPrefixResolverTypes() {
79 return prefixResolverTypes; 79 return prefixResolverTypes;
80 } 80 }
81 81
...@@ -84,7 +84,7 @@ public class YangXpathLinker<T> { ...@@ -84,7 +84,7 @@ public class YangXpathLinker<T> {
84 * 84 *
85 * @param prefixResolverTypes prefix resolver list. 85 * @param prefixResolverTypes prefix resolver list.
86 */ 86 */
87 - public void setPrefixResolverTypes(Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes) { 87 + private void setPrefixResolverTypes(Map<YangAtomicPath, PrefixResolverType> prefixResolverTypes) {
88 this.prefixResolverTypes = prefixResolverTypes; 88 this.prefixResolverTypes = prefixResolverTypes;
89 } 89 }
90 90
...@@ -188,7 +188,7 @@ public class YangXpathLinker<T> { ...@@ -188,7 +188,7 @@ public class YangXpathLinker<T> {
188 * @param leafref instance of YANG leafref 188 * @param leafref instance of YANG leafref
189 * @return linked target node 189 * @return linked target node
190 */ 190 */
191 - public T processLeafRefXpathLinking(List<YangAtomicPath> atomicPaths, YangNode root, YangLeafRef leafref) { 191 + T processLeafRefXpathLinking(List<YangAtomicPath> atomicPaths, YangNode root, YangLeafRef leafref) {
192 192
193 YangNode targetNode; 193 YangNode targetNode;
194 setRootNode(root); 194 setRootNode(root);
......
...@@ -17,9 +17,12 @@ ...@@ -17,9 +17,12 @@
17 package org.onosproject.yangutils.plugin.manager; 17 package org.onosproject.yangutils.plugin.manager;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 +import java.util.Collections;
20 import java.util.HashSet; 21 import java.util.HashSet;
22 +import java.util.LinkedList;
21 import java.util.List; 23 import java.util.List;
22 import java.util.Set; 24 import java.util.Set;
25 +
23 import org.apache.maven.artifact.repository.ArtifactRepository; 26 import org.apache.maven.artifact.repository.ArtifactRepository;
24 import org.apache.maven.plugin.AbstractMojo; 27 import org.apache.maven.plugin.AbstractMojo;
25 import org.apache.maven.plugin.MojoExecutionException; 28 import org.apache.maven.plugin.MojoExecutionException;
...@@ -42,7 +45,6 @@ import org.sonatype.plexus.build.incremental.BuildContext; ...@@ -42,7 +45,6 @@ import org.sonatype.plexus.build.incremental.BuildContext;
42 45
43 import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES; 46 import static org.apache.maven.plugins.annotations.LifecyclePhase.GENERATE_SOURCES;
44 import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE; 47 import static org.apache.maven.plugins.annotations.ResolutionScope.COMPILE;
45 -import static org.onosproject.yangutils.linker.impl.YangLinkerUtils.updateFilePriority;
46 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot; 48 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.addToCompilationRoot;
47 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget; 49 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.copyYangFilesToTarget;
48 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies; 50 import static org.onosproject.yangutils.plugin.manager.YangPluginUtils.resolveInterJarDependencies;
...@@ -68,6 +70,7 @@ public class YangUtilManager ...@@ -68,6 +70,7 @@ public class YangUtilManager
68 extends AbstractMojo { 70 extends AbstractMojo {
69 71
70 private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG); 72 private static final String DEFAULT_PKG = SLASH + getPackageDirPathFromJavaJPackage(DEFAULT_BASE_PKG);
73 + YangPluginConfig yangPlugin = new YangPluginConfig();
71 private YangNode rootNode; 74 private YangNode rootNode;
72 // YANG file information set. 75 // YANG file information set.
73 private Set<YangFileInfo> yangFileInfoSet = new HashSet<>(); 76 private Set<YangFileInfo> yangFileInfoSet = new HashSet<>();
...@@ -181,7 +184,6 @@ public class YangUtilManager ...@@ -181,7 +184,6 @@ public class YangUtilManager
181 conflictResolver.setReplacementForHyphen(replacementForHyphen); 184 conflictResolver.setReplacementForHyphen(replacementForHyphen);
182 conflictResolver.setReplacementForUnderscore(replacementForUnderscore); 185 conflictResolver.setReplacementForUnderscore(replacementForUnderscore);
183 conflictResolver.setPrefixForIdentifier(prefixForIdentifier); 186 conflictResolver.setPrefixForIdentifier(prefixForIdentifier);
184 - YangPluginConfig yangPlugin = new YangPluginConfig();
185 yangPlugin.setCodeGenDir(codeGenDir); 187 yangPlugin.setCodeGenDir(codeGenDir);
186 yangPlugin.setManagerCodeGenDir(managerCodeGenDir); 188 yangPlugin.setManagerCodeGenDir(managerCodeGenDir);
187 yangPlugin.setConflictResolver(conflictResolver); 189 yangPlugin.setConflictResolver(conflictResolver);
...@@ -223,7 +225,7 @@ public class YangUtilManager ...@@ -223,7 +225,7 @@ public class YangUtilManager
223 fileName = getCurYangFileInfo().getYangFileName(); 225 fileName = getCurYangFileInfo().getYangFileName();
224 } 226 }
225 try { 227 try {
226 - translatorErrorHandler(getRootNode()); 228 + translatorErrorHandler(getRootNode(), yangPlugin);
227 deleteDirectory(getDirectory(baseDir, classFileDir) + DEFAULT_PKG); 229 deleteDirectory(getDirectory(baseDir, classFileDir) + DEFAULT_PKG);
228 } catch (IOException ex) { 230 } catch (IOException ex) {
229 throw new MojoExecutionException( 231 throw new MojoExecutionException(
...@@ -348,8 +350,10 @@ public class YangUtilManager ...@@ -348,8 +350,10 @@ public class YangUtilManager
348 */ 350 */
349 public void translateToJava(YangPluginConfig yangPlugin) 351 public void translateToJava(YangPluginConfig yangPlugin)
350 throws IOException { 352 throws IOException {
351 - updateFilePriority(getYangNodeSet()); 353 + List<YangNode> yangNodeSortedList = new LinkedList<>();
352 - for (YangNode node : getYangNodeSet()) { 354 + yangNodeSortedList.addAll(getYangNodeSet());
355 + Collections.sort(yangNodeSortedList);
356 + for (YangNode node : yangNodeSortedList) {
353 if (node.isToTranslate()) { 357 if (node.isToTranslate()) {
354 generateJavaCode(node, yangPlugin); 358 generateJavaCode(node, yangPlugin);
355 } 359 }
......
...@@ -122,11 +122,6 @@ public final class GeneratedTempFileType { ...@@ -122,11 +122,6 @@ public final class GeneratedTempFileType {
122 public static final int EVENT_SUBJECT_SETTER_MASK = 524288; 122 public static final int EVENT_SUBJECT_SETTER_MASK = 524288;
123 123
124 /** 124 /**
125 - * Event subject setter implementation of class.
126 - */
127 - public static final int AUGMENTE_CLASS_CONSTRUCTOR_MASK = 1048576;
128 -
129 - /**
130 * Creates an instance of generated temp file type. 125 * Creates an instance of generated temp file type.
131 */ 126 */
132 private GeneratedTempFileType() { 127 private GeneratedTempFileType() {
......
...@@ -51,6 +51,16 @@ public final class JavaAttributeInfo { ...@@ -51,6 +51,16 @@ public final class JavaAttributeInfo {
51 private JavaQualifiedTypeInfo importInfo; 51 private JavaQualifiedTypeInfo importInfo;
52 52
53 /** 53 /**
54 + * If conflict occurs.
55 + */
56 + private boolean isIntConflict;
57 +
58 + /**
59 + * If conflict occurs.
60 + */
61 + private boolean isLongConflict;
62 +
63 + /**
54 * Creates a java attribute info object. 64 * Creates a java attribute info object.
55 */ 65 */
56 private JavaAttributeInfo() { 66 private JavaAttributeInfo() {
...@@ -175,6 +185,42 @@ public final class JavaAttributeInfo { ...@@ -175,6 +185,42 @@ public final class JavaAttributeInfo {
175 } 185 }
176 186
177 /** 187 /**
188 + * Returns true if conflict between int and uint.
189 + *
190 + * @return true if conflict between int and uint
191 + */
192 + public boolean isIntConflict() {
193 + return isIntConflict;
194 + }
195 +
196 + /**
197 + * Sets true if conflict between int and uint.
198 + *
199 + * @param intConflict true if conflict between int and uint
200 + */
201 + public void setIntConflict(boolean intConflict) {
202 + isIntConflict = intConflict;
203 + }
204 +
205 + /**
206 + * Returns true if conflict between long and ulong.
207 + *
208 + * @return true if conflict between long and ulong
209 + */
210 + public boolean isLongConflict() {
211 + return isLongConflict;
212 + }
213 +
214 + /**
215 + * Sets true if conflict between long and ulong.
216 + *
217 + * @param longConflict true if conflict between long and ulong
218 + */
219 + public void setLongConflict(boolean longConflict) {
220 + isLongConflict = longConflict;
221 + }
222 +
223 + /**
178 * Returns java attribute info. 224 * Returns java attribute info.
179 * 225 *
180 * @param importInfo java qualified type info 226 * @param importInfo java qualified type info
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
17 package org.onosproject.yangutils.translator.tojava; 17 package org.onosproject.yangutils.translator.tojava;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 +
20 import org.onosproject.yangutils.datamodel.TraversalType; 21 import org.onosproject.yangutils.datamodel.TraversalType;
21 import org.onosproject.yangutils.datamodel.YangNode; 22 import org.onosproject.yangutils.datamodel.YangNode;
22 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException; 23 import org.onosproject.yangutils.translator.exception.InvalidNodeForTranslatorException;
...@@ -27,6 +28,7 @@ import static org.onosproject.yangutils.datamodel.TraversalType.CHILD; ...@@ -27,6 +28,7 @@ import static org.onosproject.yangutils.datamodel.TraversalType.CHILD;
27 import static org.onosproject.yangutils.datamodel.TraversalType.PARENT; 28 import static org.onosproject.yangutils.datamodel.TraversalType.PARENT;
28 import static org.onosproject.yangutils.datamodel.TraversalType.ROOT; 29 import static org.onosproject.yangutils.datamodel.TraversalType.ROOT;
29 import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING; 30 import static org.onosproject.yangutils.datamodel.TraversalType.SIBILING;
31 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
30 32
31 /** 33 /**
32 * Representation of java code generator based on application schema. 34 * Representation of java code generator based on application schema.
...@@ -39,6 +41,11 @@ public final class JavaCodeGeneratorUtil { ...@@ -39,6 +41,11 @@ public final class JavaCodeGeneratorUtil {
39 private static YangNode curNode; 41 private static YangNode curNode;
40 42
41 /** 43 /**
44 + * Root node.
45 + */
46 + private static YangNode rootNode;
47 +
48 + /**
42 * Creates a java code generator utility object. 49 * Creates a java code generator utility object.
43 */ 50 */
44 private JavaCodeGeneratorUtil() { 51 private JavaCodeGeneratorUtil() {
...@@ -67,13 +74,14 @@ public final class JavaCodeGeneratorUtil { ...@@ -67,13 +74,14 @@ public final class JavaCodeGeneratorUtil {
67 * 74 *
68 * @param rootNode root node of the data model tree 75 * @param rootNode root node of the data model tree
69 * @param yangPlugin YANG plugin config 76 * @param yangPlugin YANG plugin config
70 - * @throws TranslatorException when fails to generate java code file the current 77 + * @throws TranslatorException when fails to generate java code file the current node
71 - * node 78 + * @throws IOException when fails to do IO operations
72 */ 79 */
73 public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin) 80 public static void generateJavaCode(YangNode rootNode, YangPluginConfig yangPlugin)
74 - throws TranslatorException { 81 + throws TranslatorException, IOException {
75 82
76 YangNode codeGenNode = rootNode; 83 YangNode codeGenNode = rootNode;
84 + setRootNode(rootNode);
77 TraversalType curTraversal = ROOT; 85 TraversalType curTraversal = ROOT;
78 86
79 while (codeGenNode != null) { 87 while (codeGenNode != null) {
...@@ -94,6 +102,7 @@ public final class JavaCodeGeneratorUtil { ...@@ -94,6 +102,7 @@ public final class JavaCodeGeneratorUtil {
94 } 102 }
95 continue; 103 continue;
96 } catch (Exception e) { 104 } catch (Exception e) {
105 + close(codeGenNode, yangPlugin);
97 throw new TranslatorException(e.getMessage()); 106 throw new TranslatorException(e.getMessage());
98 } 107 }
99 108
...@@ -103,16 +112,18 @@ public final class JavaCodeGeneratorUtil { ...@@ -103,16 +112,18 @@ public final class JavaCodeGeneratorUtil {
103 codeGenNode = codeGenNode.getChild(); 112 codeGenNode = codeGenNode.getChild();
104 } else if (codeGenNode.getNextSibling() != null) { 113 } else if (codeGenNode.getNextSibling() != null) {
105 try { 114 try {
106 - generateCodeExit(codeGenNode); 115 + generateCodeExit(codeGenNode, yangPlugin);
107 } catch (Exception e) { 116 } catch (Exception e) {
117 + close(codeGenNode, yangPlugin);
108 throw new TranslatorException(e.getMessage()); 118 throw new TranslatorException(e.getMessage());
109 } 119 }
110 curTraversal = SIBILING; 120 curTraversal = SIBILING;
111 codeGenNode = codeGenNode.getNextSibling(); 121 codeGenNode = codeGenNode.getNextSibling();
112 } else { 122 } else {
113 try { 123 try {
114 - generateCodeExit(codeGenNode); 124 + generateCodeExit(codeGenNode, yangPlugin);
115 } catch (Exception e) { 125 } catch (Exception e) {
126 + close(codeGenNode, yangPlugin);
116 throw new TranslatorException(e.getMessage()); 127 throw new TranslatorException(e.getMessage());
117 } 128 }
118 curTraversal = PARENT; 129 curTraversal = PARENT;
...@@ -124,18 +135,18 @@ public final class JavaCodeGeneratorUtil { ...@@ -124,18 +135,18 @@ public final class JavaCodeGeneratorUtil {
124 /** 135 /**
125 * Generates the current nodes code snippet. 136 * Generates the current nodes code snippet.
126 * 137 *
127 - * @param codeGenNode current data model node for which the code needs to be 138 + * @param codeGenNode current data model node for which the code needs to be generated
128 - * generated
129 * @param yangPlugin YANG plugin config 139 * @param yangPlugin YANG plugin config
130 - * @throws TranslatorException when fails to generate java code file the current 140 + * @throws TranslatorException when fails to generate java code file the current node
131 - * node 141 + * @throws IOException when fails to do IO operations
132 */ 142 */
133 private static void generateCodeEntry(YangNode codeGenNode, YangPluginConfig yangPlugin) 143 private static void generateCodeEntry(YangNode codeGenNode, YangPluginConfig yangPlugin)
134 - throws TranslatorException { 144 + throws TranslatorException, IOException {
135 145
136 if (codeGenNode instanceof JavaCodeGenerator) { 146 if (codeGenNode instanceof JavaCodeGenerator) {
137 ((JavaCodeGenerator) codeGenNode).generateCodeEntry(yangPlugin); 147 ((JavaCodeGenerator) codeGenNode).generateCodeEntry(yangPlugin);
138 } else { 148 } else {
149 + close(codeGenNode, yangPlugin);
139 throw new TranslatorException( 150 throw new TranslatorException(
140 "Generated data model node cannot be translated to target language code"); 151 "Generated data model node cannot be translated to target language code");
141 } 152 }
...@@ -144,25 +155,25 @@ public final class JavaCodeGeneratorUtil { ...@@ -144,25 +155,25 @@ public final class JavaCodeGeneratorUtil {
144 /** 155 /**
145 * Generates the current nodes code target code from the snippet. 156 * Generates the current nodes code target code from the snippet.
146 * 157 *
147 - * @param codeGenNode current data model node for which the code needs to be 158 + * @param codeGenNode current data model node for which the code needs to be generated
148 - * generated 159 + * @param pluginConfig plugin configurations
149 - * @throws TranslatorException when fails to generate java code file the current 160 + * @throws TranslatorException when fails to generate java code file the current node
150 - * node 161 + * @throws IOException when fails to do IO operations
151 */ 162 */
152 - private static void generateCodeExit(YangNode codeGenNode) 163 + private static void generateCodeExit(YangNode codeGenNode, YangPluginConfig pluginConfig)
153 - throws TranslatorException { 164 + throws TranslatorException, IOException {
154 165
155 if (codeGenNode instanceof JavaCodeGenerator) { 166 if (codeGenNode instanceof JavaCodeGenerator) {
156 ((JavaCodeGenerator) codeGenNode).generateCodeExit(); 167 ((JavaCodeGenerator) codeGenNode).generateCodeExit();
157 } else { 168 } else {
169 + close(codeGenNode, pluginConfig);
158 throw new TranslatorException( 170 throw new TranslatorException(
159 "Generated data model node cannot be translated to target language code"); 171 "Generated data model node cannot be translated to target language code");
160 } 172 }
161 } 173 }
162 174
163 /** 175 /**
164 - * Free other YANG nodes of data-model tree when error occurs while file 176 + * Free other YANG nodes of data-model tree when error occurs while file generation of current node.
165 - * generation of current node.
166 */ 177 */
167 private static void freeRestResources() { 178 private static void freeRestResources() {
168 179
...@@ -215,20 +226,17 @@ public final class JavaCodeGeneratorUtil { ...@@ -215,20 +226,17 @@ public final class JavaCodeGeneratorUtil {
215 * Delete Java code files corresponding to the YANG schema. 226 * Delete Java code files corresponding to the YANG schema.
216 * 227 *
217 * @param rootNode root node of data-model tree 228 * @param rootNode root node of data-model tree
229 + * @param yangPluginConfig plugin configurations
218 * @throws IOException when fails to delete java code file the current node 230 * @throws IOException when fails to delete java code file the current node
219 */ 231 */
220 - public static void translatorErrorHandler(YangNode rootNode) 232 + public static void translatorErrorHandler(YangNode rootNode, YangPluginConfig yangPluginConfig)
221 throws IOException { 233 throws IOException {
222 234
223 if (rootNode != null) { 235 if (rootNode != null) {
224 - /** 236 + //Free other resources where translator has failed.
225 - * Free other resources where translator has failed.
226 - */
227 freeRestResources(); 237 freeRestResources();
228 238
229 - /** 239 + // Start removing all open files.
230 - * Start removing all open files.
231 - */
232 YangNode tempNode = rootNode; 240 YangNode tempNode = rootNode;
233 setCurNode(tempNode.getChild()); 241 setCurNode(tempNode.getChild());
234 TraversalType curTraversal = ROOT; 242 TraversalType curTraversal = ROOT;
...@@ -236,7 +244,7 @@ public final class JavaCodeGeneratorUtil { ...@@ -236,7 +244,7 @@ public final class JavaCodeGeneratorUtil {
236 while (tempNode != null) { 244 while (tempNode != null) {
237 245
238 if (curTraversal != PARENT) { 246 if (curTraversal != PARENT) {
239 - close(tempNode); 247 + close(tempNode, yangPluginConfig);
240 } 248 }
241 if (curTraversal != PARENT && tempNode.getChild() != null) { 249 if (curTraversal != PARENT && tempNode.getChild() != null) {
242 curTraversal = CHILD; 250 curTraversal = CHILD;
...@@ -255,17 +263,45 @@ public final class JavaCodeGeneratorUtil { ...@@ -255,17 +263,45 @@ public final class JavaCodeGeneratorUtil {
255 } 263 }
256 264
257 /** 265 /**
258 - * Closes all the current open file handles of node and delete all generated 266 + * Closes all the current open file handles of node and delete all generated files.
259 - * files.
260 * 267 *
261 * @param node current YANG node 268 * @param node current YANG node
269 + * @param yangPlugin plugin configurations
262 * @throws IOException when fails to do IO operations 270 * @throws IOException when fails to do IO operations
263 */ 271 */
264 - private static void close(YangNode node) 272 + private static void close(YangNode node, YangPluginConfig yangPlugin)
265 throws IOException { 273 throws IOException {
266 if (node instanceof JavaCodeGenerator && ((TempJavaCodeFragmentFilesContainer) node) 274 if (node instanceof JavaCodeGenerator && ((TempJavaCodeFragmentFilesContainer) node)
267 .getTempJavaCodeFragmentFiles() != null) { 275 .getTempJavaCodeFragmentFiles() != null) {
268 ((TempJavaCodeFragmentFilesContainer) node).getTempJavaCodeFragmentFiles().freeTemporaryResources(true); 276 ((TempJavaCodeFragmentFilesContainer) node).getTempJavaCodeFragmentFiles().freeTemporaryResources(true);
277 + } else {
278 +
279 + JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) getRootNode()).getJavaFileInfo();
280 + if (javaFileInfo != null) {
281 + searchAndDeleteTempDir(javaFileInfo.getBaseCodeGenPath() +
282 + javaFileInfo.getPackageFilePath());
283 + } else {
284 + searchAndDeleteTempDir(yangPlugin.getManagerCodeGenDir());
285 + }
286 +
287 + }
269 } 288 }
289 +
290 + /**
291 + * Returns root node.
292 + *
293 + * @return root node
294 + */
295 + private static YangNode getRootNode() {
296 + return rootNode;
297 + }
298 +
299 + /**
300 + * Sets root node.
301 + *
302 + * @param rootNode root node
303 + */
304 + private static void setRootNode(YangNode rootNode) {
305 + JavaCodeGeneratorUtil.rootNode = rootNode;
270 } 306 }
271 } 307 }
......
...@@ -21,6 +21,7 @@ import java.util.SortedSet; ...@@ -21,6 +21,7 @@ import java.util.SortedSet;
21 import java.util.TreeSet; 21 import java.util.TreeSet;
22 22
23 import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT_EVENT; 23 import static org.onosproject.yangutils.utils.UtilConstants.ABSTRACT_EVENT;
24 +import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
24 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS; 25 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_CLASS;
25 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG; 26 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG;
26 import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS; 27 import static org.onosproject.yangutils.utils.UtilConstants.COLLECTION_IMPORTS;
...@@ -31,6 +32,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_I ...@@ -31,6 +32,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_I
31 import static org.onosproject.yangutils.utils.UtilConstants.HASH_MAP; 32 import static org.onosproject.yangutils.utils.UtilConstants.HASH_MAP;
32 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 33 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
33 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG; 34 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_LANG;
35 +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_MATH;
34 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_CLASS; 36 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_CLASS;
35 import static org.onosproject.yangutils.utils.UtilConstants.BITSET; 37 import static org.onosproject.yangutils.utils.UtilConstants.BITSET;
36 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG; 38 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG;
...@@ -300,4 +302,14 @@ public class JavaImportData { ...@@ -300,4 +302,14 @@ public class JavaImportData {
300 return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD + 302 return IMPORT + YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG + PERIOD +
301 YANG_AUGMENTED_OP_PARAM_INFO_CLASS; 303 YANG_AUGMENTED_OP_PARAM_INFO_CLASS;
302 } 304 }
305 +
306 + /**
307 + * Returns import for big integer.
308 + *
309 + * @return import for big integer
310 + */
311 + public String getBigIntegerImport() {
312 + return IMPORT + JAVA_MATH + PERIOD +
313 + BIG_INTEGER + SEMI_COLAN + NEW_LINE;
314 + }
303 } 315 }
......
...@@ -48,7 +48,7 @@ public class TempJavaBeanFragmentFiles ...@@ -48,7 +48,7 @@ public class TempJavaBeanFragmentFiles
48 * @param javaFileInfo generated java file info 48 * @param javaFileInfo generated java file info
49 * @throws IOException when fails to create new file handle 49 * @throws IOException when fails to create new file handle
50 */ 50 */
51 - public TempJavaBeanFragmentFiles(JavaFileInfo javaFileInfo) 51 + TempJavaBeanFragmentFiles(JavaFileInfo javaFileInfo)
52 throws IOException { 52 throws IOException {
53 53
54 super(javaFileInfo); 54 super(javaFileInfo);
...@@ -109,9 +109,7 @@ public class TempJavaBeanFragmentFiles ...@@ -109,9 +109,7 @@ public class TempJavaBeanFragmentFiles
109 /** 109 /**
110 * Removes all temporary file handles. 110 * Removes all temporary file handles.
111 * 111 *
112 - * @param isErrorOccurred when translator fails to generate java files we 112 + * @param isErrorOccurred flag to tell translator that error has occurred while code generation
113 - * need to close all open file handles include temporary files
114 - * and java files.
115 * @throws IOException when failed to delete the temporary files 113 * @throws IOException when failed to delete the temporary files
116 */ 114 */
117 @Override 115 @Override
......
...@@ -346,6 +346,10 @@ public class TempJavaCodeFragmentFiles { ...@@ -346,6 +346,10 @@ public class TempJavaCodeFragmentFiles {
346 getServiceTempFiles().freeTemporaryResources(isErrorOccurred); 346 getServiceTempFiles().freeTemporaryResources(isErrorOccurred);
347 } 347 }
348 348
349 + if (getEventFragmentFiles() != null) {
350 + getEventFragmentFiles().freeTemporaryResources(isErrorOccurred);
351 + }
352 +
349 } 353 }
350 354
351 } 355 }
......
...@@ -43,8 +43,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX; ...@@ -43,8 +43,8 @@ import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUTO_PREFIX;
43 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 43 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
44 44
45 /** 45 /**
46 - * Represents implementation of java code fragments temporary implementations. 46 + * Represents implementation of java code fragments temporary implementations. Maintains the temp files required
47 - * Maintains the temp files required specific for enumeration java snippet generation. 47 + * specific for enumeration java snippet generation.
48 */ 48 */
49 public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { 49 public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
50 50
...@@ -89,7 +89,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { ...@@ -89,7 +89,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
89 * @param javaFileInfo generated java file info 89 * @param javaFileInfo generated java file info
90 * @throws IOException when fails to create new file handle 90 * @throws IOException when fails to create new file handle
91 */ 91 */
92 - public TempJavaEnumerationFragmentFiles(JavaFileInfo javaFileInfo) 92 + TempJavaEnumerationFragmentFiles(JavaFileInfo javaFileInfo)
93 throws IOException { 93 throws IOException {
94 94
95 super(javaFileInfo); 95 super(javaFileInfo);
...@@ -107,7 +107,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { ...@@ -107,7 +107,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
107 * 107 *
108 * @return enum class java file handle 108 * @return enum class java file handle
109 */ 109 */
110 - public File getEnumClassJavaFileHandle() { 110 + private File getEnumClassJavaFileHandle() {
111 return enumClassJavaFileHandle; 111 return enumClassJavaFileHandle;
112 } 112 }
113 113
...@@ -192,14 +192,14 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { ...@@ -192,14 +192,14 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
192 * @param pluginConfig plugin configurations 192 * @param pluginConfig plugin configurations
193 * @throws IOException when fails to do IO operations 193 * @throws IOException when fails to do IO operations
194 */ 194 */
195 - public void addEnumAttributeToTempFiles(YangNode curNode, YangPluginConfig pluginConfig) throws IOException { 195 + void addEnumAttributeToTempFiles(YangNode curNode, YangPluginConfig pluginConfig) throws IOException {
196 196
197 super.addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeForEnum(pluginConfig), pluginConfig); 197 super.addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeForEnum(pluginConfig), pluginConfig);
198 if (curNode instanceof YangEnumeration) { 198 if (curNode instanceof YangEnumeration) {
199 YangEnumeration enumeration = (YangEnumeration) curNode; 199 YangEnumeration enumeration = (YangEnumeration) curNode;
200 for (YangEnum curEnum : enumeration.getEnumSet()) { 200 for (YangEnum curEnum : enumeration.getEnumSet()) {
201 String enumName = curEnum.getNamedValue(); 201 String enumName = curEnum.getNamedValue();
202 - String prefixForIdentifier = null; 202 + String prefixForIdentifier;
203 if (enumName.matches(REGEX_FOR_FIRST_DIGIT)) { 203 if (enumName.matches(REGEX_FOR_FIRST_DIGIT)) {
204 prefixForIdentifier = getPrefixForIdentifier(pluginConfig.getConflictResolver()); 204 prefixForIdentifier = getPrefixForIdentifier(pluginConfig.getConflictResolver());
205 if (prefixForIdentifier != null) { 205 if (prefixForIdentifier != null) {
...@@ -248,11 +248,10 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { ...@@ -248,11 +248,10 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
248 /** 248 /**
249 * Adds the new attribute info to the target generated temporary files. 249 * Adds the new attribute info to the target generated temporary files.
250 * 250 *
251 - * @param curEnumName the attribute name that needs to be added to temporary 251 + * @param curEnumName the attribute name that needs to be added to temporary files
252 - * files
253 * @throws IOException IO operation fail 252 * @throws IOException IO operation fail
254 */ 253 */
255 - void addJavaSnippetInfoToApplicableTempFiles(String curEnumName, YangPluginConfig pluginConfig) 254 + private void addJavaSnippetInfoToApplicableTempFiles(String curEnumName, YangPluginConfig pluginConfig)
256 throws IOException { 255 throws IOException {
257 addAttributesForEnumClass(getEnumJavaAttribute(curEnumName), pluginConfig); 256 addAttributesForEnumClass(getEnumJavaAttribute(curEnumName), pluginConfig);
258 } 257 }
...@@ -275,9 +274,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { ...@@ -275,9 +274,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
275 /** 274 /**
276 * Removes all temporary file handles. 275 * Removes all temporary file handles.
277 * 276 *
278 - * @param isErrorOccurred when translator fails to generate java files we 277 + * @param isErrorOccurred flag to tell translator that error has occurred while file generation
279 - * need to close all open file handles include temporary files
280 - * and java files.
281 * @throws IOException when failed to delete the temporary files 278 * @throws IOException when failed to delete the temporary files
282 */ 279 */
283 @Override 280 @Override
...@@ -310,7 +307,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles { ...@@ -310,7 +307,7 @@ public class TempJavaEnumerationFragmentFiles extends TempJavaFragmentFiles {
310 * 307 *
311 * @param enumStringList the enumStringList to set 308 * @param enumStringList the enumStringList to set
312 */ 309 */
313 - public void setEnumStringList(List<String> enumStringList) { 310 + private void setEnumStringList(List<String> enumStringList) {
314 this.enumStringList = enumStringList; 311 this.enumStringList = enumStringList;
315 } 312 }
316 } 313 }
......
...@@ -46,6 +46,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING; ...@@ -46,6 +46,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
46 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 46 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
47 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 47 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
48 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 48 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
49 +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
49 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; 50 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
50 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; 51 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
51 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD; 52 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.MANAGER_SETTER_METHOD;
...@@ -63,12 +64,11 @@ public class TempJavaEventFragmentFiles ...@@ -63,12 +64,11 @@ public class TempJavaEventFragmentFiles
63 /** 64 /**
64 * File name for generated class file for special type like union, typedef suffix. 65 * File name for generated class file for special type like union, typedef suffix.
65 */ 66 */
66 - public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject"; 67 + private static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject";
67 68
68 /** 69 /**
69 * File name for event enum temp file. 70 * File name for event enum temp file.
70 */ 71 */
71 -
72 private static final String EVENT_ENUM_FILE_NAME = "EventEnum"; 72 private static final String EVENT_ENUM_FILE_NAME = "EventEnum";
73 73
74 /** 74 /**
...@@ -149,7 +149,7 @@ public class TempJavaEventFragmentFiles ...@@ -149,7 +149,7 @@ public class TempJavaEventFragmentFiles
149 * @param javaFileInfo generated file information 149 * @param javaFileInfo generated file information
150 * @throws IOException when fails to create new file handle 150 * @throws IOException when fails to create new file handle
151 */ 151 */
152 - public TempJavaEventFragmentFiles(JavaFileInfo javaFileInfo) 152 + TempJavaEventFragmentFiles(JavaFileInfo javaFileInfo)
153 throws IOException { 153 throws IOException {
154 setJavaExtendsListHolder(new JavaExtendsListHolder()); 154 setJavaExtendsListHolder(new JavaExtendsListHolder());
155 setJavaImportData(new JavaImportData()); 155 setJavaImportData(new JavaImportData());
...@@ -255,6 +255,9 @@ public class TempJavaEventFragmentFiles ...@@ -255,6 +255,9 @@ public class TempJavaEventFragmentFiles
255 generateEventJavaFile(curNode); 255 generateEventJavaFile(curNode);
256 generateEventListenerJavaFile(curNode); 256 generateEventListenerJavaFile(curNode);
257 generateEventSubjectJavaFile(curNode); 257 generateEventSubjectJavaFile(curNode);
258 +
259 + // Close all the file handles.
260 + freeTemporaryResources(false);
258 } 261 }
259 262
260 /** 263 /**
...@@ -263,7 +266,7 @@ public class TempJavaEventFragmentFiles ...@@ -263,7 +266,7 @@ public class TempJavaEventFragmentFiles
263 * @param curNode current YANG node 266 * @param curNode current YANG node
264 * @throws IOException when fails to generate java files 267 * @throws IOException when fails to generate java files
265 */ 268 */
266 - public void generateEventJavaFile(YangNode curNode) 269 + private void generateEventJavaFile(YangNode curNode)
267 throws IOException { 270 throws IOException {
268 271
269 List<String> imports = new ArrayList<>(); 272 List<String> imports = new ArrayList<>();
...@@ -274,16 +277,10 @@ public class TempJavaEventFragmentFiles ...@@ -274,16 +277,10 @@ public class TempJavaEventFragmentFiles
274 277
275 addEnumMethod(nodeName, curNodeInfo + EVENT_SUBJECT_NAME_SUFFIX); 278 addEnumMethod(nodeName, curNodeInfo + EVENT_SUBJECT_NAME_SUFFIX);
276 279
277 - /** 280 + //Creates event interface file.
278 - * Creates event interface file.
279 - */
280 setEventJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + EVENT_FILE_NAME_SUFFIX)); 281 setEventJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + EVENT_FILE_NAME_SUFFIX));
281 generateEventFile(getEventJavaFileHandle(), curNode, imports); 282 generateEventFile(getEventJavaFileHandle(), curNode, imports);
282 283
283 - /**
284 - * Close all the file handles.
285 - */
286 - freeTemporaryResources(false);
287 } 284 }
288 285
289 /** 286 /**
...@@ -292,7 +289,7 @@ public class TempJavaEventFragmentFiles ...@@ -292,7 +289,7 @@ public class TempJavaEventFragmentFiles
292 * @param curNode current YANG node 289 * @param curNode current YANG node
293 * @throws IOException when fails to generate java files 290 * @throws IOException when fails to generate java files
294 */ 291 */
295 - public void generateEventListenerJavaFile(YangNode curNode) 292 + private void generateEventListenerJavaFile(YangNode curNode)
296 throws IOException { 293 throws IOException {
297 294
298 List<String> imports = new ArrayList<>(); 295 List<String> imports = new ArrayList<>();
...@@ -300,17 +297,12 @@ public class TempJavaEventFragmentFiles ...@@ -300,17 +297,12 @@ public class TempJavaEventFragmentFiles
300 imports.add(getJavaImportData().getEventListenerImport()); 297 imports.add(getJavaImportData().getEventListenerImport());
301 String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) 298 String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode)
302 .getJavaFileInfo().getJavaName()); 299 .getJavaFileInfo().getJavaName());
303 - /** 300 +
304 - * Creates event listener interface file. 301 + // Creates event listener interface file.
305 - */
306 setEventListenerJavaFileHandle( 302 setEventListenerJavaFileHandle(
307 getJavaFileHandle(curNode, curNodeInfo + EVENT_LISTENER_FILE_NAME_SUFFIX)); 303 getJavaFileHandle(curNode, curNodeInfo + EVENT_LISTENER_FILE_NAME_SUFFIX));
308 generateEventListenerFile(getEventListenerJavaFileHandle(), curNode, imports); 304 generateEventListenerFile(getEventListenerJavaFileHandle(), curNode, imports);
309 305
310 - /**
311 - * Close all the file handles.
312 - */
313 - freeTemporaryResources(false);
314 } 306 }
315 307
316 /** 308 /**
...@@ -319,22 +311,17 @@ public class TempJavaEventFragmentFiles ...@@ -319,22 +311,17 @@ public class TempJavaEventFragmentFiles
319 * @param curNode current YANG node 311 * @param curNode current YANG node
320 * @throws IOException when fails to generate java files 312 * @throws IOException when fails to generate java files
321 */ 313 */
322 - public void generateEventSubjectJavaFile(YangNode curNode) 314 + private void generateEventSubjectJavaFile(YangNode curNode)
323 throws IOException { 315 throws IOException {
324 316
325 String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode) 317 String curNodeInfo = getCapitalCase(((JavaFileInfoContainer) curNode)
326 .getJavaFileInfo().getJavaName()); 318 .getJavaFileInfo().getJavaName());
327 - /** 319 +
328 - * Creates event interface file. 320 + //Creates event interface file.
329 - */
330 setEventSubjectJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo + 321 setEventSubjectJavaFileHandle(getJavaFileHandle(curNode, curNodeInfo +
331 TempJavaEventFragmentFiles.EVENT_SUBJECT_NAME_SUFFIX)); 322 TempJavaEventFragmentFiles.EVENT_SUBJECT_NAME_SUFFIX));
332 generateEventSubjectFile(getEventSubjectJavaFileHandle(), curNode); 323 generateEventSubjectFile(getEventSubjectJavaFileHandle(), curNode);
333 324
334 - /**
335 - * Close all the file handles.
336 - */
337 - freeTemporaryResources(false);
338 } 325 }
339 326
340 /** 327 /**
...@@ -351,7 +338,7 @@ public class TempJavaEventFragmentFiles ...@@ -351,7 +338,7 @@ public class TempJavaEventFragmentFiles
351 * 338 *
352 * @param eventEnumTempFileHandle event enum temp file 339 * @param eventEnumTempFileHandle event enum temp file
353 */ 340 */
354 - public void setEventEnumTempFileHandle(File eventEnumTempFileHandle) { 341 + private void setEventEnumTempFileHandle(File eventEnumTempFileHandle) {
355 this.eventEnumTempFileHandle = eventEnumTempFileHandle; 342 this.eventEnumTempFileHandle = eventEnumTempFileHandle;
356 } 343 }
357 344
...@@ -369,7 +356,7 @@ public class TempJavaEventFragmentFiles ...@@ -369,7 +356,7 @@ public class TempJavaEventFragmentFiles
369 * 356 *
370 * @param eventMethodTempFileHandle event method temp file 357 * @param eventMethodTempFileHandle event method temp file
371 */ 358 */
372 - public void setEventMethodTempFileHandle(File eventMethodTempFileHandle) { 359 + private void setEventMethodTempFileHandle(File eventMethodTempFileHandle) {
373 this.eventMethodTempFileHandle = eventMethodTempFileHandle; 360 this.eventMethodTempFileHandle = eventMethodTempFileHandle;
374 } 361 }
375 362
...@@ -387,7 +374,7 @@ public class TempJavaEventFragmentFiles ...@@ -387,7 +374,7 @@ public class TempJavaEventFragmentFiles
387 * 374 *
388 * @param eventSubjectAttributeTempFileHandle event subject attribute temp file 375 * @param eventSubjectAttributeTempFileHandle event subject attribute temp file
389 */ 376 */
390 - public void setEventSubjectAttributeTempFileHandle(File eventSubjectAttributeTempFileHandle) { 377 + private void setEventSubjectAttributeTempFileHandle(File eventSubjectAttributeTempFileHandle) {
391 this.eventSubjectAttributeTempFileHandle = eventSubjectAttributeTempFileHandle; 378 this.eventSubjectAttributeTempFileHandle = eventSubjectAttributeTempFileHandle;
392 } 379 }
393 380
...@@ -405,7 +392,7 @@ public class TempJavaEventFragmentFiles ...@@ -405,7 +392,7 @@ public class TempJavaEventFragmentFiles
405 * 392 *
406 * @param eventSubjectGetterTempFileHandle event subject getter temp file 393 * @param eventSubjectGetterTempFileHandle event subject getter temp file
407 */ 394 */
408 - public void setEventSubjectGetterTempFileHandle(File eventSubjectGetterTempFileHandle) { 395 + private void setEventSubjectGetterTempFileHandle(File eventSubjectGetterTempFileHandle) {
409 this.eventSubjectGetterTempFileHandle = eventSubjectGetterTempFileHandle; 396 this.eventSubjectGetterTempFileHandle = eventSubjectGetterTempFileHandle;
410 } 397 }
411 398
...@@ -423,7 +410,7 @@ public class TempJavaEventFragmentFiles ...@@ -423,7 +410,7 @@ public class TempJavaEventFragmentFiles
423 * 410 *
424 * @param eventSubjectSetterTempFileHandle event subject setter temp file 411 * @param eventSubjectSetterTempFileHandle event subject setter temp file
425 */ 412 */
426 - public void setEventSubjectSetterTempFileHandle(File eventSubjectSetterTempFileHandle) { 413 + private void setEventSubjectSetterTempFileHandle(File eventSubjectSetterTempFileHandle) {
427 this.eventSubjectSetterTempFileHandle = eventSubjectSetterTempFileHandle; 414 this.eventSubjectSetterTempFileHandle = eventSubjectSetterTempFileHandle;
428 } 415 }
429 416
...@@ -434,7 +421,7 @@ public class TempJavaEventFragmentFiles ...@@ -434,7 +421,7 @@ public class TempJavaEventFragmentFiles
434 * @param pluginConfig plugin configurations 421 * @param pluginConfig plugin configurations
435 * @throws IOException when fails to do IO operations 422 * @throws IOException when fails to do IO operations
436 */ 423 */
437 - public void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig) 424 + void addJavaSnippetOfEvent(YangNode curNode, YangPluginConfig pluginConfig)
438 throws IOException { 425 throws IOException {
439 426
440 String currentInfo = getCapitalCase(getCamelCase(curNode.getName(), 427 String currentInfo = getCapitalCase(getCamelCase(curNode.getName(),
...@@ -521,4 +508,28 @@ public class TempJavaEventFragmentFiles ...@@ -521,4 +508,28 @@ public class TempJavaEventFragmentFiles
521 private String getDirPath(JavaFileInfo parentInfo) { 508 private String getDirPath(JavaFileInfo parentInfo) {
522 return (parentInfo.getPackageFilePath() + SLASH + parentInfo.getJavaName()).toLowerCase(); 509 return (parentInfo.getPackageFilePath() + SLASH + parentInfo.getJavaName()).toLowerCase();
523 } 510 }
511 +
512 + /**
513 + * Removes all temporary file handles.
514 + *
515 + * @param isErrorOccurred flag to tell translator that error has occurred while file generation
516 + * @throws IOException when failed to delete the temporary files
517 + */
518 + @Override
519 + public void freeTemporaryResources(boolean isErrorOccurred)
520 + throws IOException {
521 +
522 + closeFile(getEventJavaFileHandle(), isErrorOccurred);
523 + closeFile(getEventListenerJavaFileHandle(), isErrorOccurred);
524 + closeFile(getEventSubjectJavaFileHandle(), isErrorOccurred);
525 +
526 + closeFile(getEventEnumTempFileHandle(), true);
527 + closeFile(getEventSubjectAttributeTempFileHandle(), true);
528 + closeFile(getEventMethodTempFileHandle(), true);
529 + closeFile(getEventSubjectGetterTempFileHandle(), true);
530 + closeFile(getEventSubjectSetterTempFileHandle(), true);
531 +
532 + super.freeTemporaryResources(isErrorOccurred);
533 +
534 + }
524 } 535 }
......
...@@ -47,7 +47,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -47,7 +47,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
47 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK; 47 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
48 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; 48 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK;
49 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; 49 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
50 -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.AUGMENTE_CLASS_CONSTRUCTOR_MASK;
51 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK; 50 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
52 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; 51 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
53 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK; 52 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
...@@ -72,7 +71,6 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato ...@@ -72,7 +71,6 @@ import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerato
72 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports; 71 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.addResolvedAugmentedDataNodeImports;
73 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject; 72 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
74 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 73 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
75 -import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getAugmentedConstructor;
76 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString; 74 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
77 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString; 75 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
78 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod; 76 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
...@@ -92,7 +90,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE; ...@@ -92,7 +90,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE;
92 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT; 90 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
93 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 91 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
94 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION; 92 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
95 -import static org.onosproject.yangutils.utils.UtilConstants.IMPL;
96 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 93 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
97 import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE; 94 import static org.onosproject.yangutils.utils.UtilConstants.INTERFACE;
98 import static org.onosproject.yangutils.utils.UtilConstants.MANAGER; 95 import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
...@@ -106,7 +103,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT ...@@ -106,7 +103,6 @@ import static org.onosproject.yangutils.utils.UtilConstants.REFERENCE_CARDINALIT
106 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN; 103 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
107 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE; 104 import static org.onosproject.yangutils.utils.UtilConstants.SERVICE;
108 import static org.onosproject.yangutils.utils.UtilConstants.SLASH; 105 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
109 -import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
110 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; 106 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
111 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile; 107 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
112 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD; 108 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
...@@ -138,7 +134,7 @@ public class TempJavaFragmentFiles { ...@@ -138,7 +134,7 @@ public class TempJavaFragmentFiles {
138 /** 134 /**
139 * Folder suffix for temporary files folder. 135 * Folder suffix for temporary files folder.
140 */ 136 */
141 - private static final String TEMP_FOLDER_NAME_SUFIX = "-Temp"; 137 + private static final String TEMP_FOLDER_NAME_SUFFIX = "-Temp";
142 138
143 /** 139 /**
144 * File name for getter method. 140 * File name for getter method.
...@@ -201,16 +197,6 @@ public class TempJavaFragmentFiles { ...@@ -201,16 +197,6 @@ public class TempJavaFragmentFiles {
201 private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER; 197 private static final String BUILDER_CLASS_FILE_NAME_SUFFIX = BUILDER;
202 198
203 /** 199 /**
204 - * File name for impl class file name suffix.
205 - */
206 - private static final String IMPL_CLASS_FILE_NAME_SUFFIX = IMPL;
207 -
208 - /**
209 - * File name for augment copy constructor method.
210 - */
211 - private static final String AUGMENT_CONSTRUCTOR_FILE_NAME = "AugmentConstructor";
212 -
213 - /**
214 * Information about the java files being generated. 200 * Information about the java files being generated.
215 */ 201 */
216 private JavaFileInfo javaFileInfo; 202 private JavaFileInfo javaFileInfo;
...@@ -251,24 +237,6 @@ public class TempJavaFragmentFiles { ...@@ -251,24 +237,6 @@ public class TempJavaFragmentFiles {
251 private File builderClassJavaFileHandle; 237 private File builderClassJavaFileHandle;
252 238
253 /** 239 /**
254 - * Retrieves the temporary file handle of op param builder class.
255 - *
256 - * @return op param builder temporary file handle
257 - */
258 - public File getBuilderOpParmClassJavaFileHandle() {
259 - return builderOpParmClassJavaFileHandle;
260 - }
261 -
262 - /**
263 - * Sets the java file handle for op param builder class.
264 - *
265 - * @param builderOpParmClassJavaFileHandle java file handle
266 - */
267 - public void setBuilderOpParmClassJavaFileHandle(File builderOpParmClassJavaFileHandle) {
268 - this.builderOpParmClassJavaFileHandle = builderOpParmClassJavaFileHandle;
269 - }
270 -
271 - /**
272 * Java file handle for builder op param class file. 240 * Java file handle for builder op param class file.
273 */ 241 */
274 private File builderOpParmClassJavaFileHandle; 242 private File builderOpParmClassJavaFileHandle;
...@@ -343,11 +311,6 @@ public class TempJavaFragmentFiles { ...@@ -343,11 +311,6 @@ public class TempJavaFragmentFiles {
343 */ 311 */
344 private String baseCodePath; 312 private String baseCodePath;
345 313
346 - /**
347 - * Temporary file handle for augments copy constructor method of class.
348 - */
349 - private File augmentConstructorImplTempFileHandle;
350 -
351 TempJavaFragmentFiles() { 314 TempJavaFragmentFiles() {
352 } 315 }
353 316
...@@ -396,7 +359,6 @@ public class TempJavaFragmentFiles { ...@@ -396,7 +359,6 @@ public class TempJavaFragmentFiles {
396 addGeneratedTempFile(ATTRIBUTES_MASK); 359 addGeneratedTempFile(ATTRIBUTES_MASK);
397 addGeneratedTempFile(GETTER_FOR_CLASS_MASK); 360 addGeneratedTempFile(GETTER_FOR_CLASS_MASK);
398 addGeneratedTempFile(SETTER_FOR_CLASS_MASK); 361 addGeneratedTempFile(SETTER_FOR_CLASS_MASK);
399 - addGeneratedTempFile(AUGMENTE_CLASS_CONSTRUCTOR_MASK);
400 } 362 }
401 363
402 /* 364 /*
...@@ -465,10 +427,6 @@ public class TempJavaFragmentFiles { ...@@ -465,10 +427,6 @@ public class TempJavaFragmentFiles {
465 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { 427 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
466 setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME)); 428 setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME));
467 } 429 }
468 - if ((getGeneratedTempFiles() & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) {
469 - setAugmentConstructorImplTempFileHandle(getTemporaryFileHandle(AUGMENT_CONSTRUCTOR_FILE_NAME));
470 - }
471 -
472 } 430 }
473 431
474 /** 432 /**
...@@ -479,7 +437,7 @@ public class TempJavaFragmentFiles { ...@@ -479,7 +437,7 @@ public class TempJavaFragmentFiles {
479 * @param pluginConfig plugin configurations 437 * @param pluginConfig plugin configurations
480 * @throws IOException IO operation exception 438 * @throws IOException IO operation exception
481 */ 439 */
482 - public static void addCurNodeInfoInParentTempFile(YangNode curNode, 440 + static void addCurNodeInfoInParentTempFile(YangNode curNode,
483 boolean isList, YangPluginConfig pluginConfig) 441 boolean isList, YangPluginConfig pluginConfig)
484 throws IOException { 442 throws IOException {
485 YangNode parent = getParentNodeInGenCode(curNode); 443 YangNode parent = getParentNodeInGenCode(curNode);
...@@ -499,9 +457,7 @@ public class TempJavaFragmentFiles { ...@@ -499,9 +457,7 @@ public class TempJavaFragmentFiles {
499 457
500 JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode, 458 JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInTarget(curNode,
501 parent, isList, tempJavaBeanFragmentFiles); 459 parent, isList, tempJavaBeanFragmentFiles);
502 - if (!(parent instanceof TempJavaCodeFragmentFilesContainer)) { 460 +
503 - throw new TranslatorException("missing parent temp file handle");
504 - }
505 getNodesInterfaceFragmentFiles(parent, javaAttributeInfo, pluginConfig); 461 getNodesInterfaceFragmentFiles(parent, javaAttributeInfo, pluginConfig);
506 } 462 }
507 463
...@@ -574,7 +530,7 @@ public class TempJavaFragmentFiles { ...@@ -574,7 +530,7 @@ public class TempJavaFragmentFiles {
574 * @param config plugin configurations 530 * @param config plugin configurations
575 * @throws IOException when fails to do IO operations 531 * @throws IOException when fails to do IO operations
576 */ 532 */
577 - public static void getNodesInterfaceFragmentFiles(YangNode node, JavaAttributeInfo attr, 533 + private static void getNodesInterfaceFragmentFiles(YangNode node, JavaAttributeInfo attr,
578 YangPluginConfig config) throws IOException { 534 YangPluginConfig config) throws IOException {
579 TempJavaFragmentFiles tempJavaFragmentFiles; 535 TempJavaFragmentFiles tempJavaFragmentFiles;
580 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo(); 536 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) node).getJavaFileInfo();
...@@ -594,11 +550,73 @@ public class TempJavaFragmentFiles { ...@@ -594,11 +550,73 @@ public class TempJavaFragmentFiles {
594 } 550 }
595 551
596 /** 552 /**
553 + * Returns java attribute for leaf.
554 + *
555 + * @param tempJavaFragmentFiles temporary generated file
556 + * @param leaf YANG leaf
557 + * @param yangPluginConfig plugin configurations
558 + * @return java attribute for leaf
559 + */
560 + public static JavaAttributeInfo getJavaAttributeOfLeaf(TempJavaFragmentFiles tempJavaFragmentFiles, YangLeaf leaf,
561 + YangPluginConfig yangPluginConfig) {
562 + JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf;
563 + javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
564 + javaLeaf.updateJavaQualifiedInfo();
565 + return getAttributeInfoForTheData(
566 + javaLeaf.getJavaQualifiedInfo(),
567 + javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
568 + javaLeaf.getDataType(),
569 + tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
570 + false);
571 + }
572 +
573 + /**
574 + * Returns java attribute for leaf-list.
575 + *
576 + * @param tempJavaFragmentFiles temporary generated file
577 + * @param leafList YANG leaf-list
578 + * @param yangPluginConfig plugin configurations
579 + * @return java attribute for leaf-list
580 + */
581 + public static JavaAttributeInfo getJavaAttributeOfLeafList(TempJavaFragmentFiles tempJavaFragmentFiles,
582 + YangLeafList leafList,
583 + YangPluginConfig yangPluginConfig) {
584 + JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList;
585 + javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
586 + javaLeaf.updateJavaQualifiedInfo();
587 + tempJavaFragmentFiles.getJavaImportData().setIfListImported(true);
588 + return getAttributeInfoForTheData(
589 + javaLeaf.getJavaQualifiedInfo(),
590 + javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
591 + javaLeaf.getDataType(),
592 + tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
593 + true);
594 + }
595 +
596 + /**
597 + * Retrieves the temporary file handle of op param builder class.
598 + *
599 + * @return op param builder temporary file handle
600 + */
601 + private File getBuilderOpParmClassJavaFileHandle() {
602 + return builderOpParmClassJavaFileHandle;
603 + }
604 +
605 + /**
606 + * Sets the java file handle for op param builder class.
607 + *
608 + * @param builderOpParmClassJavaFileHandle java file handle
609 + */
610 + private void setBuilderOpParmClassJavaFileHandle(File builderOpParmClassJavaFileHandle) {
611 + this.builderOpParmClassJavaFileHandle = builderOpParmClassJavaFileHandle;
612 + }
613 +
614 + /**
597 * Returns base code path. 615 * Returns base code path.
598 * 616 *
599 * @return base code path 617 * @return base code path
600 */ 618 */
601 - public String getBaseCodePath() { 619 + private String getBaseCodePath() {
602 return baseCodePath; 620 return baseCodePath;
603 } 621 }
604 622
...@@ -607,7 +625,7 @@ public class TempJavaFragmentFiles { ...@@ -607,7 +625,7 @@ public class TempJavaFragmentFiles {
607 * 625 *
608 * @param baseCodePath base code path 626 * @param baseCodePath base code path
609 */ 627 */
610 - public void setBaseCodePath(String baseCodePath) { 628 + void setBaseCodePath(String baseCodePath) {
611 this.baseCodePath = baseCodePath; 629 this.baseCodePath = baseCodePath;
612 } 630 }
613 631
...@@ -661,18 +679,11 @@ public class TempJavaFragmentFiles { ...@@ -661,18 +679,11 @@ public class TempJavaFragmentFiles {
661 * 679 *
662 * @param fileType generated file type 680 * @param fileType generated file type
663 */ 681 */
664 - void setGeneratedTempFiles(int fileType) { 682 + private void setGeneratedTempFiles(int fileType) {
665 generatedTempFiles = fileType; 683 generatedTempFiles = fileType;
666 } 684 }
667 685
668 /** 686 /**
669 - * Clears the generated file mask.
670 - */
671 - void clearGeneratedTempFileMask() {
672 - generatedTempFiles = 0;
673 - }
674 -
675 - /**
676 * Adds to generated temporary files. 687 * Adds to generated temporary files.
677 * 688 *
678 * @param generatedTempFile generated file 689 * @param generatedTempFile generated file
...@@ -723,7 +734,7 @@ public class TempJavaFragmentFiles { ...@@ -723,7 +734,7 @@ public class TempJavaFragmentFiles {
723 * 734 *
724 * @return status of any attributes added 735 * @return status of any attributes added
725 */ 736 */
726 - public boolean isAttributePresent() { 737 + boolean isAttributePresent() {
727 return isAttributePresent; 738 return isAttributePresent;
728 } 739 }
729 740
...@@ -732,7 +743,7 @@ public class TempJavaFragmentFiles { ...@@ -732,7 +743,7 @@ public class TempJavaFragmentFiles {
732 * 743 *
733 * @param attributePresent status of any attributes added 744 * @param attributePresent status of any attributes added
734 */ 745 */
735 - public void setAttributePresent(boolean attributePresent) { 746 + private void setAttributePresent(boolean attributePresent) {
736 isAttributePresent = attributePresent; 747 isAttributePresent = attributePresent;
737 } 748 }
738 749
...@@ -894,7 +905,7 @@ public class TempJavaFragmentFiles { ...@@ -894,7 +905,7 @@ public class TempJavaFragmentFiles {
894 * 905 *
895 * @param attributeForClass file handle for attribute 906 * @param attributeForClass file handle for attribute
896 */ 907 */
897 - void setAttributesTempFileHandle(File attributeForClass) { 908 + private void setAttributesTempFileHandle(File attributeForClass) {
898 attributesTempFileHandle = attributeForClass; 909 attributesTempFileHandle = attributeForClass;
899 } 910 }
900 911
...@@ -912,7 +923,7 @@ public class TempJavaFragmentFiles { ...@@ -912,7 +923,7 @@ public class TempJavaFragmentFiles {
912 * 923 *
913 * @param getterImpl file handle for to getter method's impl 924 * @param getterImpl file handle for to getter method's impl
914 */ 925 */
915 - void setGetterImplTempFileHandle(File getterImpl) { 926 + private void setGetterImplTempFileHandle(File getterImpl) {
916 getterImplTempFileHandle = getterImpl; 927 getterImplTempFileHandle = getterImpl;
917 } 928 }
918 929
...@@ -930,12 +941,12 @@ public class TempJavaFragmentFiles { ...@@ -930,12 +941,12 @@ public class TempJavaFragmentFiles {
930 * 941 *
931 * @param hashCodeMethod file handle for hash code method 942 * @param hashCodeMethod file handle for hash code method
932 */ 943 */
933 - void setHashCodeImplTempFileHandle(File hashCodeMethod) { 944 + private void setHashCodeImplTempFileHandle(File hashCodeMethod) {
934 hashCodeImplTempFileHandle = hashCodeMethod; 945 hashCodeImplTempFileHandle = hashCodeMethod;
935 } 946 }
936 947
937 /** 948 /**
938 - * Returns equals mehtod's temporary file handle. 949 + * Returns equals method's temporary file handle.
939 * 950 *
940 * @return temporary file handle 951 * @return temporary file handle
941 */ 952 */
...@@ -948,7 +959,7 @@ public class TempJavaFragmentFiles { ...@@ -948,7 +959,7 @@ public class TempJavaFragmentFiles {
948 * 959 *
949 * @param equalsMethod file handle for to equals method 960 * @param equalsMethod file handle for to equals method
950 */ 961 */
951 - void setEqualsImplTempFileHandle(File equalsMethod) { 962 + private void setEqualsImplTempFileHandle(File equalsMethod) {
952 equalsImplTempFileHandle = equalsMethod; 963 equalsImplTempFileHandle = equalsMethod;
953 } 964 }
954 965
...@@ -966,7 +977,7 @@ public class TempJavaFragmentFiles { ...@@ -966,7 +977,7 @@ public class TempJavaFragmentFiles {
966 * 977 *
967 * @param toStringMethod file handle for to string method 978 * @param toStringMethod file handle for to string method
968 */ 979 */
969 - void setToStringImplTempFileHandle(File toStringMethod) { 980 + private void setToStringImplTempFileHandle(File toStringMethod) {
970 toStringImplTempFileHandle = toStringMethod; 981 toStringImplTempFileHandle = toStringMethod;
971 } 982 }
972 983
...@@ -984,29 +995,11 @@ public class TempJavaFragmentFiles { ...@@ -984,29 +995,11 @@ public class TempJavaFragmentFiles {
984 * 995 *
985 * @param javaExtendsListHolder java extends list holder 996 * @param javaExtendsListHolder java extends list holder
986 */ 997 */
987 - public void setJavaExtendsListHolder(JavaExtendsListHolder javaExtendsListHolder) { 998 + void setJavaExtendsListHolder(JavaExtendsListHolder javaExtendsListHolder) {
988 this.javaExtendsListHolder = javaExtendsListHolder; 999 this.javaExtendsListHolder = javaExtendsListHolder;
989 } 1000 }
990 1001
991 /** 1002 /**
992 - * Returns augments copy constructor method impl class file.
993 - *
994 - * @return augments copy constructor method impl class file
995 - */
996 - public File getAugmentConstructorImplTempFileHandle() {
997 - return augmentConstructorImplTempFileHandle;
998 - }
999 -
1000 - /**
1001 - * Sets augments copy constructor method impl class.
1002 - *
1003 - * @param augmentConstructorImplTempFileHandle augments copy constructor method impl class file
1004 - */
1005 - public void setAugmentConstructorImplTempFileHandle(File augmentConstructorImplTempFileHandle) {
1006 - this.augmentConstructorImplTempFileHandle = augmentConstructorImplTempFileHandle;
1007 - }
1008 -
1009 - /**
1010 * Adds attribute for class. 1003 * Adds attribute for class.
1011 * 1004 *
1012 * @param attr attribute info 1005 * @param attr attribute info
...@@ -1056,8 +1049,7 @@ public class TempJavaFragmentFiles { ...@@ -1056,8 +1049,7 @@ public class TempJavaFragmentFiles {
1056 throws IOException { 1049 throws IOException {
1057 appendToFile(getSetterImplTempFileHandle(), 1050 appendToFile(getSetterImplTempFileHandle(),
1058 getOverRideString() + getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles()) 1051 getOverRideString() + getSetterForClass(attr, getGeneratedJavaClassName(), getGeneratedJavaFiles())
1059 - + 1052 + + NEW_LINE);
1060 - NEW_LINE);
1061 } 1053 }
1062 1054
1063 /** 1055 /**
...@@ -1067,7 +1059,7 @@ public class TempJavaFragmentFiles { ...@@ -1067,7 +1059,7 @@ public class TempJavaFragmentFiles {
1067 * @param pluginConfig plugin configurations 1059 * @param pluginConfig plugin configurations
1068 * @throws IOException when fails to append to temporary file 1060 * @throws IOException when fails to append to temporary file
1069 */ 1061 */
1070 - private void addGetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig) 1062 + void addGetterImpl(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
1071 throws IOException { 1063 throws IOException {
1072 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0 1064 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0
1073 || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) { 1065 || (getGeneratedJavaFiles() & GENERATE_SERVICE_AND_MANAGER) != 0) {
...@@ -1158,7 +1150,7 @@ public class TempJavaFragmentFiles { ...@@ -1158,7 +1150,7 @@ public class TempJavaFragmentFiles {
1158 * @param fromStringAttributeInfo from string attribute info 1150 * @param fromStringAttributeInfo from string attribute info
1159 * @throws IOException when fails to append to temporary file 1151 * @throws IOException when fails to append to temporary file
1160 */ 1152 */
1161 - private void addFromStringMethod(JavaAttributeInfo javaAttributeInfo, 1153 + void addFromStringMethod(JavaAttributeInfo javaAttributeInfo,
1162 JavaAttributeInfo fromStringAttributeInfo) 1154 JavaAttributeInfo fromStringAttributeInfo)
1163 throws IOException { 1155 throws IOException {
1164 appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo, 1156 appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo,
...@@ -1166,17 +1158,6 @@ public class TempJavaFragmentFiles { ...@@ -1166,17 +1158,6 @@ public class TempJavaFragmentFiles {
1166 } 1158 }
1167 1159
1168 /** 1160 /**
1169 - * Adds constructor for augment class.
1170 - *
1171 - * @param attr attribute info
1172 - * @throws IOException when fails to append to temporary file
1173 - */
1174 - private void addAugmentConstructor(JavaAttributeInfo attr, YangPluginConfig pluginConfig)
1175 - throws IOException {
1176 - appendToFile(getAugmentConstructorImplTempFileHandle(), getAugmentedConstructor(attr, pluginConfig));
1177 - }
1178 -
1179 - /**
1180 * Returns a temporary file handle for the specific file type. 1161 * Returns a temporary file handle for the specific file type.
1181 * 1162 *
1182 * @param fileName file name 1163 * @param fileName file name
...@@ -1237,9 +1218,9 @@ public class TempJavaFragmentFiles { ...@@ -1237,9 +1218,9 @@ public class TempJavaFragmentFiles {
1237 * @param absolutePath absolute path 1218 * @param absolutePath absolute path
1238 * @return directory path 1219 * @return directory path
1239 */ 1220 */
1240 - String getTempDirPath(String absolutePath) { 1221 + private String getTempDirPath(String absolutePath) {
1241 return getPackageDirPathFromJavaJPackage(absolutePath) + SLASH + getGeneratedJavaClassName() 1222 return getPackageDirPathFromJavaJPackage(absolutePath) + SLASH + getGeneratedJavaClassName()
1242 - + TEMP_FOLDER_NAME_SUFIX + SLASH; 1223 + + TEMP_FOLDER_NAME_SUFFIX + SLASH;
1243 } 1224 }
1244 1225
1245 /** 1226 /**
...@@ -1249,7 +1230,7 @@ public class TempJavaFragmentFiles { ...@@ -1249,7 +1230,7 @@ public class TempJavaFragmentFiles {
1249 * @param pluginConfig plugin configurations 1230 * @param pluginConfig plugin configurations
1250 * @return attribute string 1231 * @return attribute string
1251 */ 1232 */
1252 - public String parseAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) { 1233 + String parseAttribute(JavaAttributeInfo attr, YangPluginConfig pluginConfig) {
1253 /* 1234 /*
1254 * TODO: check if this utility needs to be called or move to the caller 1235 * TODO: check if this utility needs to be called or move to the caller
1255 */ 1236 */
...@@ -1290,7 +1271,7 @@ public class TempJavaFragmentFiles { ...@@ -1290,7 +1271,7 @@ public class TempJavaFragmentFiles {
1290 * @param curNode current node for which import list needs to be updated 1271 * @param curNode current node for which import list needs to be updated
1291 * @param pluginConfig plugin configurations 1272 * @param pluginConfig plugin configurations
1292 */ 1273 */
1293 - public void addParentInfoInCurNodeTempFile(YangNode curNode, YangPluginConfig pluginConfig) { 1274 + void addParentInfoInCurNodeTempFile(YangNode curNode, YangPluginConfig pluginConfig) {
1294 caseImportInfo = new JavaQualifiedTypeInfo(); 1275 caseImportInfo = new JavaQualifiedTypeInfo();
1295 YangNode parent = getParentNodeInGenCode(curNode); 1276 YangNode parent = getParentNodeInGenCode(curNode);
1296 if (!(parent instanceof JavaCodeGenerator)) { 1277 if (!(parent instanceof JavaCodeGenerator)) {
...@@ -1316,41 +1297,28 @@ public class TempJavaFragmentFiles { ...@@ -1316,41 +1297,28 @@ public class TempJavaFragmentFiles {
1316 * 1297 *
1317 * @param listOfLeaves list of YANG leaf 1298 * @param listOfLeaves list of YANG leaf
1318 * @param yangPluginConfig plugin config 1299 * @param yangPluginConfig plugin config
1300 + * @param curNode current node
1319 * @throws IOException IO operation fail 1301 * @throws IOException IO operation fail
1320 */ 1302 */
1321 - public void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves, 1303 + private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves,
1322 - YangPluginConfig yangPluginConfig) 1304 + YangPluginConfig yangPluginConfig, YangNode curNode)
1323 throws IOException { 1305 throws IOException {
1324 if (listOfLeaves != null) { 1306 if (listOfLeaves != null) {
1325 for (YangLeaf leaf : listOfLeaves) { 1307 for (YangLeaf leaf : listOfLeaves) {
1326 if (!(leaf instanceof JavaLeafInfoContainer)) { 1308 if (!(leaf instanceof JavaLeafInfoContainer)) {
1327 throw new TranslatorException("Leaf does not have java information"); 1309 throw new TranslatorException("Leaf does not have java information");
1328 } 1310 }
1311 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1312 + TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1313 + .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1314 + addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(tempJavaBeanFragmentFiles, leaf,
1315 + yangPluginConfig), yangPluginConfig);
1316 + } else {
1329 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(this, leaf, yangPluginConfig), 1317 addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeaf(this, leaf, yangPluginConfig),
1330 yangPluginConfig); 1318 yangPluginConfig);
1331 } 1319 }
1332 } 1320 }
1333 } 1321 }
1334 -
1335 - /**
1336 - * Returns java attribute for leaf.
1337 - *
1338 - * @param tempJavaFragmentFiles temporary generated file
1339 - * @param leaf YANG leaf
1340 - * @param yangPluginConfig plugin configurations
1341 - * @return java attribute for leaf
1342 - */
1343 - public static JavaAttributeInfo getJavaAttributeOfLeaf(TempJavaFragmentFiles tempJavaFragmentFiles, YangLeaf leaf,
1344 - YangPluginConfig yangPluginConfig) {
1345 - JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leaf;
1346 - javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
1347 - javaLeaf.updateJavaQualifiedInfo();
1348 - return getAttributeInfoForTheData(
1349 - javaLeaf.getJavaQualifiedInfo(),
1350 - javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
1351 - javaLeaf.getDataType(),
1352 - tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
1353 - false);
1354 } 1322 }
1355 1323
1356 /** 1324 /**
...@@ -1358,60 +1326,45 @@ public class TempJavaFragmentFiles { ...@@ -1358,60 +1326,45 @@ public class TempJavaFragmentFiles {
1358 * 1326 *
1359 * @param listOfLeafList list of YANG leaves 1327 * @param listOfLeafList list of YANG leaves
1360 * @param yangPluginConfig plugin config 1328 * @param yangPluginConfig plugin config
1329 + * @param curNode current node
1361 * @throws IOException IO operation fail 1330 * @throws IOException IO operation fail
1362 */ 1331 */
1363 - public void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, YangPluginConfig yangPluginConfig) 1332 + private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList, YangPluginConfig yangPluginConfig,
1364 - throws IOException { 1333 + YangNode curNode) throws IOException {
1365 if (listOfLeafList != null) { 1334 if (listOfLeafList != null) {
1366 for (YangLeafList leafList : listOfLeafList) { 1335 for (YangLeafList leafList : listOfLeafList) {
1367 if (!(leafList instanceof JavaLeafInfoContainer)) { 1336 if (!(leafList instanceof JavaLeafInfoContainer)) {
1368 throw new TranslatorException("Leaf-list does not have java information"); 1337 throw new TranslatorException("Leaf-list does not have java information");
1369 } 1338 }
1370 - addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(this, leafList, yangPluginConfig), 1339 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
1371 - yangPluginConfig); 1340 + TempJavaBeanFragmentFiles tempJavaBeanFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
1341 + .getTempJavaCodeFragmentFiles().getBeanTempFiles();
1342 + addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(tempJavaBeanFragmentFiles,
1343 + leafList, yangPluginConfig), yangPluginConfig);
1344 + } else {
1345 + addJavaSnippetInfoToApplicableTempFiles(getJavaAttributeOfLeafList(this,
1346 + leafList, yangPluginConfig), yangPluginConfig);
1372 } 1347 }
1373 } 1348 }
1374 } 1349 }
1375 -
1376 - /**
1377 - * Returns java attribute for leaf-list.
1378 - *
1379 - * @param tempJavaFragmentFiles temporary generated file
1380 - * @param leafList YANG leaf-list
1381 - * @param yangPluginConfig plugin configurations
1382 - * @return java attribute for leaf-list
1383 - */
1384 - public static JavaAttributeInfo getJavaAttributeOfLeafList(TempJavaFragmentFiles tempJavaFragmentFiles,
1385 - YangLeafList leafList, YangPluginConfig yangPluginConfig) {
1386 - JavaLeafInfoContainer javaLeaf = (JavaLeafInfoContainer) leafList;
1387 - javaLeaf.setConflictResolveConfig(yangPluginConfig.getConflictResolver());
1388 - javaLeaf.updateJavaQualifiedInfo();
1389 - tempJavaFragmentFiles.getJavaImportData().setIfListImported(true);
1390 - return getAttributeInfoForTheData(
1391 - javaLeaf.getJavaQualifiedInfo(),
1392 - javaLeaf.getJavaName(yangPluginConfig.getConflictResolver()),
1393 - javaLeaf.getDataType(),
1394 - tempJavaFragmentFiles.getIsQualifiedAccessOrAddToImportList(javaLeaf.getJavaQualifiedInfo()),
1395 - true);
1396 } 1350 }
1397 1351
1398 /** 1352 /**
1399 - * Adds all the leaves in the current data model node as part of the 1353 + * Adds all the leaves in the current data model node as part of the generated temporary file.
1400 - * generated temporary file.
1401 * 1354 *
1402 - * @param curNode java file info of the generated file 1355 + * @param curNode current node
1403 * @param yangPluginConfig plugin config 1356 * @param yangPluginConfig plugin config
1404 * @throws IOException IO operation fail 1357 * @throws IOException IO operation fail
1405 */ 1358 */
1406 - public void addCurNodeLeavesInfoToTempFiles(YangNode curNode, 1359 + void addCurNodeLeavesInfoToTempFiles(YangNode curNode,
1407 YangPluginConfig yangPluginConfig) 1360 YangPluginConfig yangPluginConfig)
1408 throws IOException { 1361 throws IOException {
1409 if (!(curNode instanceof YangLeavesHolder)) { 1362 if (!(curNode instanceof YangLeavesHolder)) {
1410 throw new TranslatorException("Data model node does not have any leaves"); 1363 throw new TranslatorException("Data model node does not have any leaves");
1411 } 1364 }
1412 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode; 1365 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
1413 - addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), yangPluginConfig); 1366 + addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), yangPluginConfig, curNode);
1414 - addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), yangPluginConfig); 1367 + addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), yangPluginConfig, curNode);
1415 } 1368 }
1416 1369
1417 /** 1370 /**
...@@ -1440,9 +1393,6 @@ public class TempJavaFragmentFiles { ...@@ -1440,9 +1393,6 @@ public class TempJavaFragmentFiles {
1440 addSetterImpl(newAttrInfo); 1393 addSetterImpl(newAttrInfo);
1441 } 1394 }
1442 1395
1443 - if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
1444 - addGetterImpl(newAttrInfo, pluginConfig);
1445 - }
1446 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) { 1396 if ((getGeneratedTempFiles() & HASH_CODE_IMPL_MASK) != 0) {
1447 addHashCodeMethod(newAttrInfo); 1397 addHashCodeMethod(newAttrInfo);
1448 } 1398 }
...@@ -1453,6 +1403,12 @@ public class TempJavaFragmentFiles { ...@@ -1453,6 +1403,12 @@ public class TempJavaFragmentFiles {
1453 addToStringMethod(newAttrInfo); 1403 addToStringMethod(newAttrInfo);
1454 } 1404 }
1455 1405
1406 + if (!newAttrInfo.isIntConflict() &&
1407 + !newAttrInfo.isLongConflict()) {
1408 + if ((getGeneratedTempFiles() & GETTER_FOR_CLASS_MASK) != 0) {
1409 + addGetterImpl(newAttrInfo, pluginConfig);
1410 + }
1411 +
1456 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { 1412 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
1457 JavaQualifiedTypeInfo qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo, 1413 JavaQualifiedTypeInfo qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo,
1458 pluginConfig.getConflictResolver()); 1414 pluginConfig.getConflictResolver());
...@@ -1468,6 +1424,7 @@ public class TempJavaFragmentFiles { ...@@ -1468,6 +1424,7 @@ public class TempJavaFragmentFiles {
1468 addFromStringMethod(newAttrInfo, fromStringAttributeInfo); 1424 addFromStringMethod(newAttrInfo, fromStringAttributeInfo);
1469 } 1425 }
1470 } 1426 }
1427 + }
1471 1428
1472 /** 1429 /**
1473 * Returns java class name. 1430 * Returns java class name.
...@@ -1484,7 +1441,7 @@ public class TempJavaFragmentFiles { ...@@ -1484,7 +1441,7 @@ public class TempJavaFragmentFiles {
1484 * 1441 *
1485 * @return java class name 1442 * @return java class name
1486 */ 1443 */
1487 - String getImplClassName() { 1444 + private String getImplClassName() {
1488 return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName()); 1445 return getCapitalCase(DEFAULT) + getCapitalCase(getJavaFileInfo().getJavaName());
1489 } 1446 }
1490 1447
...@@ -1493,7 +1450,7 @@ public class TempJavaFragmentFiles { ...@@ -1493,7 +1450,7 @@ public class TempJavaFragmentFiles {
1493 * 1450 *
1494 * @return op param java class name 1451 * @return op param java class name
1495 */ 1452 */
1496 - String getOpParamImplClassName() { 1453 + private String getOpParamImplClassName() {
1497 return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION; 1454 return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION;
1498 } 1455 }
1499 1456
...@@ -1502,7 +1459,7 @@ public class TempJavaFragmentFiles { ...@@ -1502,7 +1459,7 @@ public class TempJavaFragmentFiles {
1502 * 1459 *
1503 * @return op param builder java class name 1460 * @return op param builder java class name
1504 */ 1461 */
1505 - String getOpParamBuilderImplClassName() { 1462 + private String getOpParamBuilderImplClassName() {
1506 return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION + BUILDER; 1463 return getCapitalCase(getJavaFileInfo().getJavaName()) + OPERATION + BUILDER;
1507 } 1464 }
1508 1465
...@@ -1533,8 +1490,6 @@ public class TempJavaFragmentFiles { ...@@ -1533,8 +1490,6 @@ public class TempJavaFragmentFiles {
1533 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles() 1490 List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getBeanTempFiles()
1534 .getJavaImportData().getImports(); 1491 .getJavaImportData().getImports();
1535 1492
1536 - JavaFileInfo curInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
1537 -
1538 createPackage(curNode); 1493 createPackage(curNode);
1539 1494
1540 /* 1495 /*
...@@ -1620,7 +1575,7 @@ public class TempJavaFragmentFiles { ...@@ -1620,7 +1575,7 @@ public class TempJavaFragmentFiles {
1620 qualifiedTypeInfo.setPkgInfo(getJavaFileInfo().getPackage()); 1575 qualifiedTypeInfo.setPkgInfo(getJavaFileInfo().getPackage());
1621 getJavaExtendsListHolder().addToExtendsList(qualifiedTypeInfo, curNode, 1576 getJavaExtendsListHolder().addToExtendsList(qualifiedTypeInfo, curNode,
1622 tempJavaBeanFragmentFiles); 1577 tempJavaBeanFragmentFiles);
1623 - addBitsetImport(imports, true); 1578 + addBitSetImport(imports, true);
1624 if (curNode instanceof YangAugment) { 1579 if (curNode instanceof YangAugment) {
1625 addYangAugmentedOpParamInfoImport(imports); 1580 addYangAugmentedOpParamInfoImport(imports);
1626 } 1581 }
...@@ -1646,7 +1601,7 @@ public class TempJavaFragmentFiles { ...@@ -1646,7 +1601,7 @@ public class TempJavaFragmentFiles {
1646 mergeJavaFiles(getBuilderOpParmClassJavaFileHandle(), getOpParamClassJavaFileHandle()); 1601 mergeJavaFiles(getBuilderOpParmClassJavaFileHandle(), getOpParamClassJavaFileHandle());
1647 validateLineLength(getOpParamClassJavaFileHandle()); 1602 validateLineLength(getOpParamClassJavaFileHandle());
1648 1603
1649 - addBitsetImport(imports, false); 1604 + addBitSetImport(imports, false);
1650 } 1605 }
1651 insertDataIntoJavaFile(getOpParamClassJavaFileHandle(), getJavaClassDefClose()); 1606 insertDataIntoJavaFile(getOpParamClassJavaFileHandle(), getJavaClassDefClose());
1652 1607
...@@ -1669,7 +1624,7 @@ public class TempJavaFragmentFiles { ...@@ -1669,7 +1624,7 @@ public class TempJavaFragmentFiles {
1669 * @param imports import list 1624 * @param imports import list
1670 * @param operation add or remove 1625 * @param operation add or remove
1671 */ 1626 */
1672 - public void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) { 1627 + void addImportsToStringAndHasCodeMethods(List<String> imports, boolean operation) {
1673 if (operation) { 1628 if (operation) {
1674 imports.add(getJavaImportData().getImportForHashAndEquals()); 1629 imports.add(getJavaImportData().getImportForHashAndEquals());
1675 imports.add(getJavaImportData().getImportForToString()); 1630 imports.add(getJavaImportData().getImportForToString());
...@@ -1680,12 +1635,12 @@ public class TempJavaFragmentFiles { ...@@ -1680,12 +1635,12 @@ public class TempJavaFragmentFiles {
1680 } 1635 }
1681 1636
1682 /** 1637 /**
1683 - * Adds imports for bitset method. 1638 + * Adds imports for bitSet method.
1684 * 1639 *
1685 * @param imports import list 1640 * @param imports import list
1686 * @param operation add or remove 1641 * @param operation add or remove
1687 */ 1642 */
1688 - public void addBitsetImport(List<String> imports, boolean operation) { 1643 + private void addBitSetImport(List<String> imports, boolean operation) {
1689 if (operation) { 1644 if (operation) {
1690 imports.add(getJavaImportData().getImportForToBitSet()); 1645 imports.add(getJavaImportData().getImportForToBitSet());
1691 } else { 1646 } else {
...@@ -1700,7 +1655,7 @@ public class TempJavaFragmentFiles { ...@@ -1700,7 +1655,7 @@ public class TempJavaFragmentFiles {
1700 * @param imports import list 1655 * @param imports import list
1701 * @param operations true for adding and false for deletion 1656 * @param operations true for adding and false for deletion
1702 */ 1657 */
1703 - public void addImportsForAugmentableClass(List<String> imports, boolean operations) { 1658 + private void addImportsForAugmentableClass(List<String> imports, boolean operations) {
1704 if (operations) { 1659 if (operations) {
1705 imports.add(getJavaImportData().getHashMapImport()); 1660 imports.add(getJavaImportData().getHashMapImport());
1706 imports.add(getJavaImportData().getMapImport()); 1661 imports.add(getJavaImportData().getMapImport());
...@@ -1730,34 +1685,24 @@ public class TempJavaFragmentFiles { ...@@ -1730,34 +1685,24 @@ public class TempJavaFragmentFiles {
1730 * Removes case import info from import list. 1685 * Removes case import info from import list.
1731 * 1686 *
1732 * @param imports list of imports 1687 * @param imports list of imports
1733 - * @return import for class
1734 */ 1688 */
1735 private void removeAugmentedInfoImport(List<String> imports) { 1689 private void removeAugmentedInfoImport(List<String> imports) {
1736 imports.remove(getJavaImportData().getYangAugmentedInfoImport()); 1690 imports.remove(getJavaImportData().getYangAugmentedInfoImport());
1737 -
1738 - for (JavaQualifiedTypeInfo type : getJavaImportData().getImportSet()) {
1739 - if (type.getClassInfo().equals(YANG_AUGMENTED_INFO)) {
1740 - getJavaImportData().getImportSet().remove(type);
1741 - getJavaExtendsListHolder().getExtendsList().remove(type);
1742 - }
1743 - }
1744 } 1691 }
1745 1692
1746 /** 1693 /**
1747 * Removes all temporary file handles. 1694 * Removes all temporary file handles.
1748 * 1695 *
1749 - * @param isErrorOccurred when translator fails to generate java files we need to close all open file handles 1696 + * @param isErrorOccurred flag to tell translator that error has occurred while file generation
1750 - * include temporary files and java files.
1751 * @throws IOException when failed to delete the temporary files 1697 * @throws IOException when failed to delete the temporary files
1752 */ 1698 */
1753 public void freeTemporaryResources(boolean isErrorOccurred) 1699 public void freeTemporaryResources(boolean isErrorOccurred)
1754 throws IOException { 1700 throws IOException {
1755 - boolean isError = isErrorOccurred;
1756 /* 1701 /*
1757 * Close all java file handles and when error occurs delete the files. 1702 * Close all java file handles and when error occurs delete the files.
1758 */ 1703 */
1759 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) { 1704 if ((getGeneratedJavaFiles() & INTERFACE_MASK) != 0) {
1760 - closeFile(getInterfaceJavaFileHandle(), isError); 1705 + closeFile(getInterfaceJavaFileHandle(), isErrorOccurred);
1761 } 1706 }
1762 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) { 1707 if ((getGeneratedJavaFiles() & BUILDER_CLASS_MASK) != 0) {
1763 closeFile(getBuilderClassJavaFileHandle(), true); 1708 closeFile(getBuilderClassJavaFileHandle(), true);
...@@ -1769,7 +1714,7 @@ public class TempJavaFragmentFiles { ...@@ -1769,7 +1714,7 @@ public class TempJavaFragmentFiles {
1769 closeFile(getBuilderInterfaceJavaFileHandle(), true); 1714 closeFile(getBuilderInterfaceJavaFileHandle(), true);
1770 } 1715 }
1771 if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) { 1716 if ((getGeneratedJavaFiles() & IMPL_CLASS_MASK) != 0) {
1772 - closeFile(getImplClassJavaFileHandle(), isError); 1717 + closeFile(getImplClassJavaFileHandle(), isErrorOccurred);
1773 } 1718 }
1774 1719
1775 /* 1720 /*
...@@ -1793,9 +1738,6 @@ public class TempJavaFragmentFiles { ...@@ -1793,9 +1738,6 @@ public class TempJavaFragmentFiles {
1793 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) { 1738 if ((getGeneratedTempFiles() & FROM_STRING_IMPL_MASK) != 0) {
1794 closeFile(getFromStringImplTempFileHandle(), true); 1739 closeFile(getFromStringImplTempFileHandle(), true);
1795 } 1740 }
1796 - if ((getGeneratedTempFiles() & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) {
1797 - closeFile(getAugmentConstructorImplTempFileHandle(), true);
1798 - }
1799 } 1741 }
1800 1742
1801 /** 1743 /**
...@@ -1805,7 +1747,7 @@ public class TempJavaFragmentFiles { ...@@ -1805,7 +1747,7 @@ public class TempJavaFragmentFiles {
1805 * @param importInfo import info for the current attribute being added 1747 * @param importInfo import info for the current attribute being added
1806 * @return status of the qualified access to the attribute 1748 * @return status of the qualified access to the attribute
1807 */ 1749 */
1808 - public boolean getIsQualifiedAccessOrAddToImportList( 1750 + boolean getIsQualifiedAccessOrAddToImportList(
1809 JavaQualifiedTypeInfo importInfo) { 1751 JavaQualifiedTypeInfo importInfo) {
1810 1752
1811 return getJavaImportData().addImportInfo(importInfo, getGeneratedJavaClassName(), 1753 return getJavaImportData().addImportInfo(importInfo, getGeneratedJavaClassName(),
...@@ -1817,7 +1759,7 @@ public class TempJavaFragmentFiles { ...@@ -1817,7 +1759,7 @@ public class TempJavaFragmentFiles {
1817 * 1759 *
1818 * @return java file handle for op param class file 1760 * @return java file handle for op param class file
1819 */ 1761 */
1820 - public File getOpParamClassJavaFileHandle() { 1762 + private File getOpParamClassJavaFileHandle() {
1821 return opParamClassJavaFileHandle; 1763 return opParamClassJavaFileHandle;
1822 } 1764 }
1823 1765
...@@ -1826,7 +1768,7 @@ public class TempJavaFragmentFiles { ...@@ -1826,7 +1768,7 @@ public class TempJavaFragmentFiles {
1826 * 1768 *
1827 * @param opParamClassJavaFileHandle java file handle 1769 * @param opParamClassJavaFileHandle java file handle
1828 */ 1770 */
1829 - public void setOpParamClassJavaFileHandle(File opParamClassJavaFileHandle) { 1771 + private void setOpParamClassJavaFileHandle(File opParamClassJavaFileHandle) {
1830 this.opParamClassJavaFileHandle = opParamClassJavaFileHandle; 1772 this.opParamClassJavaFileHandle = opParamClassJavaFileHandle;
1831 } 1773 }
1832 } 1774 }
......
...@@ -78,7 +78,7 @@ public class TempJavaServiceFragmentFiles ...@@ -78,7 +78,7 @@ public class TempJavaServiceFragmentFiles
78 /** 78 /**
79 * Flag to set the manager files generation. 79 * Flag to set the manager files generation.
80 */ 80 */
81 - boolean isManagerNeedToBeGenerated = false; 81 + private boolean isManagerNeedToBeGenerated = false;
82 82
83 /** 83 /**
84 * Temporary file handle for rpc interface. 84 * Temporary file handle for rpc interface.
...@@ -96,7 +96,7 @@ public class TempJavaServiceFragmentFiles ...@@ -96,7 +96,7 @@ public class TempJavaServiceFragmentFiles
96 private File serviceInterfaceJavaFileHandle; 96 private File serviceInterfaceJavaFileHandle;
97 97
98 /** 98 /**
99 - * Path for serive file to be generated. 99 + * Path for service file to be generated.
100 */ 100 */
101 private String serviceGenPath; 101 private String serviceGenPath;
102 102
...@@ -111,7 +111,7 @@ public class TempJavaServiceFragmentFiles ...@@ -111,7 +111,7 @@ public class TempJavaServiceFragmentFiles
111 * @param javaFileInfo generated file information 111 * @param javaFileInfo generated file information
112 * @throws IOException when fails to create new file handle 112 * @throws IOException when fails to create new file handle
113 */ 113 */
114 - public TempJavaServiceFragmentFiles(JavaFileInfo javaFileInfo) 114 + TempJavaServiceFragmentFiles(JavaFileInfo javaFileInfo)
115 throws IOException { 115 throws IOException {
116 setJavaExtendsListHolder(new JavaExtendsListHolder()); 116 setJavaExtendsListHolder(new JavaExtendsListHolder());
117 setJavaImportData(new JavaImportData()); 117 setJavaImportData(new JavaImportData());
...@@ -150,7 +150,7 @@ public class TempJavaServiceFragmentFiles ...@@ -150,7 +150,7 @@ public class TempJavaServiceFragmentFiles
150 * 150 *
151 * @return java file handle 151 * @return java file handle
152 */ 152 */
153 - public File getManagerJavaFileHandle() { 153 + private File getManagerJavaFileHandle() {
154 return managerJavaFileHandle; 154 return managerJavaFileHandle;
155 } 155 }
156 156
...@@ -159,7 +159,7 @@ public class TempJavaServiceFragmentFiles ...@@ -159,7 +159,7 @@ public class TempJavaServiceFragmentFiles
159 * 159 *
160 * @param managerJavaFileHandle file handle for to manager 160 * @param managerJavaFileHandle file handle for to manager
161 */ 161 */
162 - public void setManagerJavaFileHandle(File managerJavaFileHandle) { 162 + private void setManagerJavaFileHandle(File managerJavaFileHandle) {
163 this.managerJavaFileHandle = managerJavaFileHandle; 163 this.managerJavaFileHandle = managerJavaFileHandle;
164 } 164 }
165 165
...@@ -195,7 +195,7 @@ public class TempJavaServiceFragmentFiles ...@@ -195,7 +195,7 @@ public class TempJavaServiceFragmentFiles
195 * 195 *
196 * @param rpcImplTempFileHandle the manager impl temp file 196 * @param rpcImplTempFileHandle the manager impl temp file
197 */ 197 */
198 - public void setRpcImplTempFileHandle(File rpcImplTempFileHandle) { 198 + private void setRpcImplTempFileHandle(File rpcImplTempFileHandle) {
199 this.rpcImplTempFileHandle = rpcImplTempFileHandle; 199 this.rpcImplTempFileHandle = rpcImplTempFileHandle;
200 } 200 }
201 201
...@@ -226,9 +226,8 @@ public class TempJavaServiceFragmentFiles ...@@ -226,9 +226,8 @@ public class TempJavaServiceFragmentFiles
226 if (isNotification) { 226 if (isNotification) {
227 addListenersImport(curNode, imports, true, LISTENER_SERVICE); 227 addListenersImport(curNode, imports, true, LISTENER_SERVICE);
228 } 228 }
229 - /** 229 +
230 - * Creates rpc interface file. 230 + // Creates rpc interface file.
231 - */
232 setBaseCodePath(getServiceGenPath()); 231 setBaseCodePath(getServiceGenPath());
233 setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX))); 232 setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX)));
234 generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports); 233 generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports);
...@@ -238,9 +237,8 @@ public class TempJavaServiceFragmentFiles ...@@ -238,9 +237,8 @@ public class TempJavaServiceFragmentFiles
238 addListenersImport(curNode, imports, true, LISTENER_REG); 237 addListenersImport(curNode, imports, true, LISTENER_REG);
239 } 238 }
240 addAnnotationsImports(imports, true); 239 addAnnotationsImports(imports, true);
241 - /** 240 +
242 - * Create builder class file. 241 + // Create builder class file.
243 - */
244 if (isManagerNeedToBeGenerated()) { 242 if (isManagerNeedToBeGenerated()) {
245 setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX))); 243 setManagerJavaFileHandle(getJavaFileHandle(getJavaClassName(MANAGER_FILE_NAME_SUFFIX)));
246 generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode); 244 generateManagerClassFile(getManagerJavaFileHandle(), imports, curNode);
...@@ -251,17 +249,16 @@ public class TempJavaServiceFragmentFiles ...@@ -251,17 +249,16 @@ public class TempJavaServiceFragmentFiles
251 } 249 }
252 addAnnotationsImports(imports, false); 250 addAnnotationsImports(imports, false);
253 251
254 - /** 252 +
255 - * Close all the file handles. 253 + // Close all the file handles.
256 - */
257 freeTemporaryResources(false); 254 freeTemporaryResources(false);
258 } 255 }
259 256
260 /** 257 /**
261 * Adds rpc string information to applicable temp file. 258 * Adds rpc string information to applicable temp file.
262 * 259 *
263 - * @param javaAttributeInfoOfInput rpc's input node attribute info 260 + * @param javaAttributeInfoOfInput RPCs input node attribute info
264 - * @param javaAttributeInfoOfOutput rpc's output node attribute info 261 + * @param javaAttributeInfoOfOutput RPCs output node attribute info
265 * @param rpcName name of the rpc function 262 * @param rpcName name of the rpc function
266 * @param pluginConfig plugin configurations 263 * @param pluginConfig plugin configurations
267 * @throws IOException IO operation fail 264 * @throws IOException IO operation fail
...@@ -292,8 +289,8 @@ public class TempJavaServiceFragmentFiles ...@@ -292,8 +289,8 @@ public class TempJavaServiceFragmentFiles
292 /** 289 /**
293 * Adds the JAVA rpc snippet information. 290 * Adds the JAVA rpc snippet information.
294 * 291 *
295 - * @param javaAttributeInfoOfInput rpc's input node attribute info 292 + * @param javaAttributeInfoOfInput RPCs input node attribute info
296 - * @param javaAttributeInfoOfOutput rpc's output node attribute info 293 + * @param javaAttributeInfoOfOutput RPCs output node attribute info
297 * @param pluginConfig plugin configurations 294 * @param pluginConfig plugin configurations
298 * @param rpcName name of the rpc function 295 * @param rpcName name of the rpc function
299 * @throws IOException IO operation fail 296 * @throws IOException IO operation fail
...@@ -308,17 +305,15 @@ public class TempJavaServiceFragmentFiles ...@@ -308,17 +305,15 @@ public class TempJavaServiceFragmentFiles
308 /** 305 /**
309 * Removes all temporary file handles. 306 * Removes all temporary file handles.
310 * 307 *
311 - * @param isErrorOccurred when translator fails to generate java files we need to close all open file handles 308 + * @param isErrorOccurred flag to tell translator that error has occurred while file generation
312 - * include temporary files and java files.
313 * @throws IOException when failed to delete the temporary files 309 * @throws IOException when failed to delete the temporary files
314 */ 310 */
315 @Override 311 @Override
316 public void freeTemporaryResources(boolean isErrorOccurred) 312 public void freeTemporaryResources(boolean isErrorOccurred)
317 throws IOException { 313 throws IOException {
318 - boolean isError = isErrorOccurred;
319 314
320 - closeFile(getServiceInterfaceJavaFileHandle(), isError); 315 + closeFile(getServiceInterfaceJavaFileHandle(), isErrorOccurred);
321 - closeFile(getManagerJavaFileHandle(), isError); 316 + closeFile(getManagerJavaFileHandle(), isErrorOccurred);
322 317
323 closeFile(getRpcInterfaceTempFileHandle(), true); 318 closeFile(getRpcInterfaceTempFileHandle(), true);
324 closeFile(getRpcImplTempFileHandle(), true); 319 closeFile(getRpcImplTempFileHandle(), true);
...@@ -335,7 +330,7 @@ public class TempJavaServiceFragmentFiles ...@@ -335,7 +330,7 @@ public class TempJavaServiceFragmentFiles
335 * 330 *
336 * @return path where service file should be generated 331 * @return path where service file should be generated
337 */ 332 */
338 - public String getServiceGenPath() { 333 + private String getServiceGenPath() {
339 return serviceGenPath; 334 return serviceGenPath;
340 } 335 }
341 336
...@@ -344,7 +339,7 @@ public class TempJavaServiceFragmentFiles ...@@ -344,7 +339,7 @@ public class TempJavaServiceFragmentFiles
344 * 339 *
345 * @param serviceGenPath path where service file should be generated 340 * @param serviceGenPath path where service file should be generated
346 */ 341 */
347 - public void setServiceGenPath(String serviceGenPath) { 342 + private void setServiceGenPath(String serviceGenPath) {
348 this.serviceGenPath = serviceGenPath; 343 this.serviceGenPath = serviceGenPath;
349 } 344 }
350 345
...@@ -353,7 +348,7 @@ public class TempJavaServiceFragmentFiles ...@@ -353,7 +348,7 @@ public class TempJavaServiceFragmentFiles
353 * 348 *
354 * @return true if manager needs to be generated 349 * @return true if manager needs to be generated
355 */ 350 */
356 - public boolean isManagerNeedToBeGenerated() { 351 + private boolean isManagerNeedToBeGenerated() {
357 return isManagerNeedToBeGenerated; 352 return isManagerNeedToBeGenerated;
358 } 353 }
359 354
......
...@@ -24,29 +24,37 @@ import java.util.List; ...@@ -24,29 +24,37 @@ import java.util.List;
24 import org.onosproject.yangutils.datamodel.YangNode; 24 import org.onosproject.yangutils.datamodel.YangNode;
25 import org.onosproject.yangutils.datamodel.YangType; 25 import org.onosproject.yangutils.datamodel.YangType;
26 import org.onosproject.yangutils.datamodel.YangTypeHolder; 26 import org.onosproject.yangutils.datamodel.YangTypeHolder;
27 +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
27 import org.onosproject.yangutils.translator.exception.TranslatorException; 28 import org.onosproject.yangutils.translator.exception.TranslatorException;
28 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType; 29 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaType;
29 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 30 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
30 31
32 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32;
33 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64;
34 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16;
35 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32;
31 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS; 36 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
32 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS; 37 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
33 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; 38 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
34 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK; 39 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
35 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK; 40 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.OF_STRING_IMPL_MASK;
36 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData; 41 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoForTheData;
42 +import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedInfoOfFromString;
37 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile; 43 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile;
38 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile; 44 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile;
39 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 45 +import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
40 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc; 46 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc;
41 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc; 47 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getTypeConstructorStringAndJavaDoc;
42 -import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile; 48 +import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.INT_TYPE_CONFLICT;
49 +import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.LONG_TYPE_CONFLICT;
43 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 50 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
44 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 51 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
45 -import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.createPackage; 52 +import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
53 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
46 54
47 /** 55 /**
48 - * Represents implementation of java data type code fragments temporary implementations. 56 + * Represents implementation of java data type code fragments temporary implementations. Maintains the temp files
49 - * Maintains the temp files required specific for user defined data type java snippet generation. 57 + * required specific for user defined data type java snippet generation.
50 */ 58 */
51 public class TempJavaTypeFragmentFiles 59 public class TempJavaTypeFragmentFiles
52 extends TempJavaFragmentFiles { 60 extends TempJavaFragmentFiles {
...@@ -67,12 +75,31 @@ public class TempJavaTypeFragmentFiles ...@@ -67,12 +75,31 @@ public class TempJavaTypeFragmentFiles
67 private static final String TYPEDEF_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; 75 private static final String TYPEDEF_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING;
68 76
69 /** 77 /**
70 - * File name for generated class file for special type like union, typedef 78 + * File name for generated class file for special type like union, typedef suffix.
71 - * suffix.
72 */ 79 */
73 private static final String UNION_TYPE_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING; 80 private static final String UNION_TYPE_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING;
74 81
75 /** 82 /**
83 + * Integer index in type list.
84 + */
85 + private int intIndex = 0;
86 +
87 + /**
88 + * UInt index in type list.
89 + */
90 + private int uIntIndex = 0;
91 +
92 + /**
93 + * long index in type list.
94 + */
95 + private int longIndex = 0;
96 +
97 + /**
98 + * ULong index in type list.
99 + */
100 + private int uLongIndex = 0;
101 +
102 + /**
76 * Temporary file handle for of string method of class. 103 * Temporary file handle for of string method of class.
77 */ 104 */
78 private File ofStringImplTempFileHandle; 105 private File ofStringImplTempFileHandle;
...@@ -93,12 +120,32 @@ public class TempJavaTypeFragmentFiles ...@@ -93,12 +120,32 @@ public class TempJavaTypeFragmentFiles
93 private File typeClassJavaFileHandle; 120 private File typeClassJavaFileHandle;
94 121
95 /** 122 /**
123 + * Java attribute for int.
124 + */
125 + private JavaAttributeInfo intAttribute;
126 +
127 + /**
128 + * Java attribute for long.
129 + */
130 + private JavaAttributeInfo longAttribute;
131 +
132 + /**
133 + * Java attribute for uInt.
134 + */
135 + private JavaAttributeInfo uIntAttribute;
136 +
137 + /**
138 + * Java attribute for uLong.
139 + */
140 + private JavaAttributeInfo uLongAttribute;
141 +
142 + /**
96 * Creates an instance of temporary java code fragment. 143 * Creates an instance of temporary java code fragment.
97 * 144 *
98 * @param javaFileInfo generated java file info 145 * @param javaFileInfo generated java file info
99 * @throws IOException when fails to create new file handle 146 * @throws IOException when fails to create new file handle
100 */ 147 */
101 - public TempJavaTypeFragmentFiles(JavaFileInfo javaFileInfo) 148 + TempJavaTypeFragmentFiles(JavaFileInfo javaFileInfo)
102 throws IOException { 149 throws IOException {
103 150
104 super(javaFileInfo); 151 super(javaFileInfo);
...@@ -129,8 +176,7 @@ public class TempJavaTypeFragmentFiles ...@@ -129,8 +176,7 @@ public class TempJavaTypeFragmentFiles
129 /** 176 /**
130 * Sets type class constructor method's temporary file handle. 177 * Sets type class constructor method's temporary file handle.
131 * 178 *
132 - * @param constructorForTypeTempFileHandle type class constructor method's 179 + * @param constructorForTypeTempFileHandle type class constructor method's temporary file handle
133 - * temporary file handle
134 */ 180 */
135 private void setConstructorForTypeTempFileHandle(File constructorForTypeTempFileHandle) { 181 private void setConstructorForTypeTempFileHandle(File constructorForTypeTempFileHandle) {
136 this.constructorForTypeTempFileHandle = constructorForTypeTempFileHandle; 182 this.constructorForTypeTempFileHandle = constructorForTypeTempFileHandle;
...@@ -141,7 +187,7 @@ public class TempJavaTypeFragmentFiles ...@@ -141,7 +187,7 @@ public class TempJavaTypeFragmentFiles
141 * 187 *
142 * @return java file handle for typedef class file 188 * @return java file handle for typedef class file
143 */ 189 */
144 - File getTypedefClassJavaFileHandle() { 190 + private File getTypedefClassJavaFileHandle() {
145 return typedefClassJavaFileHandle; 191 return typedefClassJavaFileHandle;
146 } 192 }
147 193
...@@ -159,7 +205,7 @@ public class TempJavaTypeFragmentFiles ...@@ -159,7 +205,7 @@ public class TempJavaTypeFragmentFiles
159 * 205 *
160 * @return java file handle for type class file 206 * @return java file handle for type class file
161 */ 207 */
162 - File getTypeClassJavaFileHandle() { 208 + private File getTypeClassJavaFileHandle() {
163 return typeClassJavaFileHandle; 209 return typeClassJavaFileHandle;
164 } 210 }
165 211
...@@ -185,23 +231,20 @@ public class TempJavaTypeFragmentFiles ...@@ -185,23 +231,20 @@ public class TempJavaTypeFragmentFiles
185 /** 231 /**
186 * Set of string method's temporary file handle. 232 * Set of string method's temporary file handle.
187 * 233 *
188 - * @param ofStringImplTempFileHandle of string method's temporary file 234 + * @param ofStringImplTempFileHandle of string method's temporary file handle
189 - * handle
190 */ 235 */
191 private void setOfStringImplTempFileHandle(File ofStringImplTempFileHandle) { 236 private void setOfStringImplTempFileHandle(File ofStringImplTempFileHandle) {
192 this.ofStringImplTempFileHandle = ofStringImplTempFileHandle; 237 this.ofStringImplTempFileHandle = ofStringImplTempFileHandle;
193 } 238 }
194 239
195 /** 240 /**
196 - * Adds all the type in the current data model node as part of the generated 241 + * Adds all the type in the current data model node as part of the generated temporary file.
197 - * temporary file.
198 * 242 *
199 - * @param yangTypeHolder YANG java data model node which has type info, eg union / 243 + * @param yangTypeHolder YANG java data model node which has type info, eg union / typedef
200 - * typedef
201 * @param pluginConfig plugin configurations for naming conventions 244 * @param pluginConfig plugin configurations for naming conventions
202 * @throws IOException IO operation fail 245 * @throws IOException IO operation fail
203 */ 246 */
204 - public void addTypeInfoToTempFiles(YangTypeHolder yangTypeHolder, YangPluginConfig pluginConfig) 247 + void addTypeInfoToTempFiles(YangTypeHolder yangTypeHolder, YangPluginConfig pluginConfig)
205 throws IOException { 248 throws IOException {
206 249
207 List<YangType<?>> typeList = yangTypeHolder.getTypeList(); 250 List<YangType<?>> typeList = yangTypeHolder.getTypeList();
...@@ -210,46 +253,162 @@ public class TempJavaTypeFragmentFiles ...@@ -210,46 +253,162 @@ public class TempJavaTypeFragmentFiles
210 if (!(yangType instanceof YangJavaType)) { 253 if (!(yangType instanceof YangJavaType)) {
211 throw new TranslatorException("Type does not have Java info"); 254 throw new TranslatorException("Type does not have Java info");
212 } 255 }
256 + JavaAttributeInfo javaAttributeInfo = getAttributeForType(yangType, pluginConfig);
257 + addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo,
258 + pluginConfig, typeList);
259 + }
260 + addTypeConstructor(pluginConfig);
261 + addMethodsInConflictCase(pluginConfig);
262 + }
263 + }
264 +
265 + /**
266 + * Returns java attribute.
267 + *
268 + * @param yangType YANG type
269 + * @param pluginConfig plugin configurations
270 + * @return java attribute
271 + */
272 + private JavaAttributeInfo getAttributeForType(YangType yangType, YangPluginConfig pluginConfig) {
213 YangJavaType<?> javaType = (YangJavaType<?>) yangType; 273 YangJavaType<?> javaType = (YangJavaType<?>) yangType;
214 javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver()); 274 javaType.updateJavaQualifiedInfo(pluginConfig.getConflictResolver());
215 String typeName = javaType.getDataTypeName(); 275 String typeName = javaType.getDataTypeName();
216 typeName = getCamelCase(typeName, pluginConfig.getConflictResolver()); 276 typeName = getCamelCase(typeName, pluginConfig.getConflictResolver());
217 - JavaAttributeInfo javaAttributeInfo = getAttributeInfoForTheData( 277 + return getAttributeInfoForTheData(
218 javaType.getJavaQualifiedInfo(), 278 javaType.getJavaQualifiedInfo(),
219 typeName, javaType, 279 typeName, javaType,
220 getIsQualifiedAccessOrAddToImportList(javaType.getJavaQualifiedInfo()), 280 getIsQualifiedAccessOrAddToImportList(javaType.getJavaQualifiedInfo()),
221 false); 281 false);
222 - addJavaSnippetInfoToApplicableTempFiles((YangNode) yangTypeHolder, javaAttributeInfo,
223 - pluginConfig);
224 - }
225 - }
226 } 282 }
227 283
228 /** 284 /**
229 - * Adds the new attribute info to the target generated temporary files for 285 + * Adds the new attribute info to the target generated temporary files for union class.
230 - * union class.
231 * 286 *
232 - * @param hasType the node for which the type is being added as an attribute 287 + * @param javaAttributeInfo the attribute info that needs to be added to temporary files
233 - * @param javaAttributeInfo the attribute info that needs to be added to
234 - * temporary files
235 * @param pluginConfig plugin configurations 288 * @param pluginConfig plugin configurations
289 + * @param typeList type list
236 * @throws IOException IO operation fail 290 * @throws IOException IO operation fail
237 */ 291 */
238 - private void addJavaSnippetInfoToApplicableTempFiles(YangNode hasType, JavaAttributeInfo javaAttributeInfo, 292 + private void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfo,
239 - YangPluginConfig pluginConfig) 293 + YangPluginConfig pluginConfig, List<YangType<?>> typeList)
240 throws IOException { 294 throws IOException {
241 295
296 + YangDataTypes attrType = javaAttributeInfo.getAttributeType().getDataType();
297 +
298 + if (attrType == INT32 || attrType == UINT16) {
299 + boolean isIntConflict = validateForConflictingIntTypes(typeList);
300 + javaAttributeInfo.setIntConflict(isIntConflict);
301 + updateAttributeCondition(javaAttributeInfo);
302 + if (!isIntConflict) {
303 + addMethodsWhenNoConflictingTypes(javaAttributeInfo, pluginConfig);
304 + }
305 + } else if (attrType == INT64 || attrType == UINT32) {
306 + boolean isLongConflict = validateForConflictingLongTypes(typeList);
307 + javaAttributeInfo.setLongConflict(isLongConflict);
308 + updateAttributeCondition(javaAttributeInfo);
309 + if (!isLongConflict) {
310 + addMethodsWhenNoConflictingTypes(javaAttributeInfo, pluginConfig);
311 + }
312 + } else {
313 + addMethodsWhenNoConflictingTypes(javaAttributeInfo, pluginConfig);
314 + }
242 super.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig); 315 super.addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo, pluginConfig);
243 316
317 + }
318 +
319 + /**
320 + * Adds of method and constructor when there is no conflictiing types.
321 + *
322 + * @param javaAttributeInfo java attribute info
323 + * @param pluginConfig plugin configurations
324 + * @throws IOException when fails to do IO opearions
325 + */
326 + private void addMethodsWhenNoConflictingTypes(JavaAttributeInfo javaAttributeInfo,
327 + YangPluginConfig pluginConfig) throws IOException {
244 if ((getGeneratedTempFiles() & OF_STRING_IMPL_MASK) != 0) { 328 if ((getGeneratedTempFiles() & OF_STRING_IMPL_MASK) != 0) {
245 addOfStringMethod(javaAttributeInfo, pluginConfig); 329 addOfStringMethod(javaAttributeInfo, pluginConfig);
246 } 330 }
331 +
247 if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { 332 if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) {
248 addTypeConstructor(javaAttributeInfo, pluginConfig); 333 addTypeConstructor(javaAttributeInfo, pluginConfig);
249 } 334 }
250 } 335 }
251 336
252 /** 337 /**
338 + * Adds of, getter and from string method in conflict cases.
339 + *
340 + * @param pluginConfig plugin configurations
341 + * @throws IOException when fails to do IO operations
342 + */
343 + private void addMethodsInConflictCase(YangPluginConfig pluginConfig) throws IOException {
344 + JavaAttributeInfo attr = getIntAttribute();
345 + if (attr != null) {
346 + attr = getUIntAttribute();
347 + }
348 + if (attr != null) {
349 + if (attr.isIntConflict()) {
350 + if (getIntIndex() < getUIntIndex()) {
351 + appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getIntAttribute(),
352 + getGeneratedJavaClassName(), pluginConfig)
353 + + NEW_LINE);
354 + addGetterImpl(getIntAttribute(), pluginConfig);
355 + addFromStringMethod(getIntAttribute(), pluginConfig);
356 + } else {
357 + appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getUIntAttribute(),
358 + getGeneratedJavaClassName(), pluginConfig)
359 + + NEW_LINE);
360 + addGetterImpl(getUIntAttribute(), pluginConfig);
361 + addFromStringMethod(getUIntAttribute(), pluginConfig);
362 + }
363 + }
364 + }
365 + attr = getLongAttribute();
366 + if (attr != null) {
367 + attr = getULongAttribute();
368 + }
369 + if (attr != null) {
370 + if (attr.isLongConflict()) {
371 + if (getLongIndex() < getULongIndex()) {
372 + appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getLongAttribute(),
373 + getGeneratedJavaClassName(), pluginConfig)
374 + + NEW_LINE);
375 + addGetterImpl(getLongAttribute(), pluginConfig);
376 + addFromStringMethod(getLongAttribute(), pluginConfig);
377 + } else {
378 + appendToFile(getOfStringImplTempFileHandle(), getOfMethodStringAndJavaDoc(getULongAttribute(),
379 + getGeneratedJavaClassName(), pluginConfig)
380 + + NEW_LINE);
381 + addGetterImpl(getULongAttribute(), pluginConfig);
382 + addFromStringMethod(getULongAttribute(), pluginConfig);
383 + }
384 + }
385 + }
386 + }
387 +
388 + /**
389 + * Adds from string method for conflict case.
390 + *
391 + * @param newAttrInfo new attribute
392 + * @param pluginConfig plugin configurations
393 + * @throws IOException when fails to do IO operations
394 + */
395 + private void addFromStringMethod(JavaAttributeInfo newAttrInfo, YangPluginConfig pluginConfig) throws IOException {
396 +
397 + JavaQualifiedTypeInfo qualifiedInfoOfFromString = getQualifiedInfoOfFromString(newAttrInfo,
398 + pluginConfig.getConflictResolver());
399 + /*
400 + * Create a new java attribute info with qualified information of
401 + * wrapper classes.
402 + */
403 + JavaAttributeInfo fromStringAttributeInfo = getAttributeInfoForTheData(qualifiedInfoOfFromString,
404 + newAttrInfo.getAttributeName(),
405 + newAttrInfo.getAttributeType(),
406 + getIsQualifiedAccessOrAddToImportList(qualifiedInfoOfFromString), false);
407 +
408 + addFromStringMethod(newAttrInfo, fromStringAttributeInfo);
409 + }
410 +
411 + /**
253 * Adds type constructor. 412 * Adds type constructor.
254 * 413 *
255 * @param attr attribute info 414 * @param attr attribute info
...@@ -263,6 +422,42 @@ public class TempJavaTypeFragmentFiles ...@@ -263,6 +422,42 @@ public class TempJavaTypeFragmentFiles
263 } 422 }
264 423
265 /** 424 /**
425 + * Adds type constructor.
426 + *
427 + * @param pluginConfig plugin configurations
428 + * @throws IOException when fails to append to temporary file
429 + */
430 + private void addTypeConstructor(YangPluginConfig pluginConfig)
431 + throws IOException {
432 + JavaAttributeInfo attr = getIntAttribute();
433 + if (attr != null) {
434 + attr = getUIntAttribute();
435 + }
436 + if (attr != null) {
437 + if (attr.isIntConflict()) {
438 + appendToFile(getConstructorForTypeTempFileHandle(), getTypeConstructorStringAndJavaDoc(
439 + getIntAttribute(),
440 + getUIntAttribute(), getGeneratedJavaClassName(), pluginConfig, INT_TYPE_CONFLICT,
441 + getIntIndex()
442 + < getUIntIndex()) + NEW_LINE);
443 + }
444 + }
445 + attr = getLongAttribute();
446 + if (attr != null) {
447 + attr = getULongAttribute();
448 + }
449 + if (attr != null) {
450 + if (attr.isLongConflict()) {
451 + appendToFile(getConstructorForTypeTempFileHandle(), getTypeConstructorStringAndJavaDoc(
452 + getLongAttribute(),
453 + getULongAttribute(), getGeneratedJavaClassName(), pluginConfig, LONG_TYPE_CONFLICT,
454 + getLongIndex()
455 + < getULongIndex()) + NEW_LINE);
456 + }
457 + }
458 + }
459 +
460 + /**
266 * Adds of string for type. 461 * Adds of string for type.
267 * 462 *
268 * @param attr attribute info 463 * @param attr attribute info
...@@ -279,22 +474,19 @@ public class TempJavaTypeFragmentFiles ...@@ -279,22 +474,19 @@ public class TempJavaTypeFragmentFiles
279 /** 474 /**
280 * Removes all temporary file handles. 475 * Removes all temporary file handles.
281 * 476 *
282 - * @param isErrorOccurred when translator fails to generate java files we 477 + * @param isErrorOccurred flag to tell translator that error has occurred while file generation
283 - * need to close all open file handles include temporary files
284 - * and java files.
285 * @throws IOException when failed to delete the temporary files 478 * @throws IOException when failed to delete the temporary files
286 */ 479 */
287 @Override 480 @Override
288 public void freeTemporaryResources(boolean isErrorOccurred) 481 public void freeTemporaryResources(boolean isErrorOccurred)
289 throws IOException { 482 throws IOException {
290 - boolean isError = isErrorOccurred;
291 483
292 if ((getGeneratedJavaFiles() & GENERATE_TYPEDEF_CLASS) != 0) { 484 if ((getGeneratedJavaFiles() & GENERATE_TYPEDEF_CLASS) != 0) {
293 - closeFile(getTypedefClassJavaFileHandle(), isError); 485 + closeFile(getTypedefClassJavaFileHandle(), isErrorOccurred);
294 } 486 }
295 487
296 if ((getGeneratedJavaFiles() & GENERATE_UNION_CLASS) != 0) { 488 if ((getGeneratedJavaFiles() & GENERATE_UNION_CLASS) != 0) {
297 - closeFile(getTypeClassJavaFileHandle(), isError); 489 + closeFile(getTypeClassJavaFileHandle(), isErrorOccurred);
298 } 490 }
299 491
300 if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) { 492 if ((getGeneratedTempFiles() & CONSTRUCTOR_FOR_TYPE_MASK) != 0) {
...@@ -350,4 +542,219 @@ public class TempJavaTypeFragmentFiles ...@@ -350,4 +542,219 @@ public class TempJavaTypeFragmentFiles
350 */ 542 */
351 freeTemporaryResources(false); 543 freeTemporaryResources(false);
352 } 544 }
545 +
546 + /**
547 + * Returns int type index from type list.
548 + *
549 + * @return int type index from type list
550 + */
551 + public int getIntIndex() {
552 + return intIndex;
553 + }
554 +
555 + /**
556 + * Sets int type index from type list.
557 + *
558 + * @param intIndex int type index from type list.
559 + */
560 + private void setIntIndex(int intIndex) {
561 + this.intIndex = intIndex;
562 + }
563 +
564 + /**
565 + * Returns uInt type index from type list.
566 + *
567 + * @return uInt type index from type list
568 + */
569 + public int getUIntIndex() {
570 + return uIntIndex;
571 + }
572 +
573 + /**
574 + * Sets uInt type index from type list.
575 + *
576 + * @param uIntIndex uInt type index from type list.
577 + */
578 + private void setUIntIndex(int uIntIndex) {
579 + this.uIntIndex = uIntIndex;
580 + }
581 +
582 + /**
583 + * Returns long type index from type list.
584 + *
585 + * @return long type index from type list
586 + */
587 + public int getLongIndex() {
588 + return longIndex;
589 + }
590 +
591 + /**
592 + * Sets long type index from type list.
593 + *
594 + * @param longIndex long type index from type list.
595 + */
596 + private void setLongIndex(int longIndex) {
597 + this.longIndex = longIndex;
598 + }
599 +
600 + /**
601 + * Returns uLong type index from type list.
602 + *
603 + * @return uLong type index from type list
604 + */
605 + public int getULongIndex() {
606 + return uLongIndex;
607 + }
608 +
609 + /**
610 + * Sets uLong type index from type list.
611 + *
612 + * @param uLongIndex uLong type index from type list.
613 + */
614 + private void setULongIndex(int uLongIndex) {
615 + this.uLongIndex = uLongIndex;
616 + }
617 +
618 + /**
619 + * Validates conflict for int and uInt.
620 + *
621 + * @param typeList type list
622 + * @return true if conflict is there
623 + */
624 + private boolean validateForConflictingIntTypes(List<YangType<?>> typeList) {
625 + boolean isIntPresent = false;
626 + boolean isUIntPresent = false;
627 + for (YangType type : typeList) {
628 + if (type.getDataType().equals(INT32)) {
629 + setIntIndex(typeList.indexOf(type));
630 + isIntPresent = true;
631 + }
632 + if (type.getDataType().equals(UINT16)) {
633 + setUIntIndex(typeList.indexOf(type));
634 + isUIntPresent = true;
635 + }
636 + }
637 +
638 + return isIntPresent && isUIntPresent;
639 + }
640 +
641 + /**
642 + * Validates conflict for long and uLong.
643 + *
644 + * @param typeList type list
645 + * @return true if conflict is there
646 + */
647 + private boolean validateForConflictingLongTypes(List<YangType<?>> typeList) {
648 + boolean isLongPresent = false;
649 + boolean isULongPresent = false;
650 + for (YangType type : typeList) {
651 + if (type.getDataType().equals(INT64)) {
652 + setLongIndex(typeList.indexOf(type));
653 + isLongPresent = true;
654 + }
655 + if (type.getDataType().equals(UINT32)) {
656 + setULongIndex(typeList.indexOf(type));
657 + isULongPresent = true;
658 + }
659 + }
660 +
661 + return isLongPresent && isULongPresent;
662 + }
663 +
664 + /**
665 + * Updates attribute info in case of conflicts.
666 + *
667 + * @param javaAttributeInfo java attribute info
668 + */
669 + private void updateAttributeCondition(JavaAttributeInfo javaAttributeInfo) {
670 +
671 + if (javaAttributeInfo.isIntConflict()) {
672 + if (javaAttributeInfo.getAttributeType().getDataType() == UINT16) {
673 + setUIntAttribute(javaAttributeInfo);
674 + } else if (javaAttributeInfo.getAttributeType().getDataType() == INT32) {
675 + setIntAttribute(javaAttributeInfo);
676 + }
677 +
678 + }
679 + if (javaAttributeInfo.isLongConflict()) {
680 + if (javaAttributeInfo.getAttributeType().getDataType() == UINT32) {
681 + setULongAttribute(javaAttributeInfo);
682 + } else if (javaAttributeInfo.getAttributeType().getDataType() == INT64) {
683 + setLongAttribute(javaAttributeInfo);
684 + }
685 +
686 + }
687 + }
688 +
689 + /**
690 + * Returns attribute for int.
691 + *
692 + * @return attribute for int
693 + */
694 + public JavaAttributeInfo getIntAttribute() {
695 + return intAttribute;
696 + }
697 +
698 + /**
699 + * Sets attribute for int.
700 + *
701 + * @param intAttribute attribute for int
702 + */
703 + private void setIntAttribute(JavaAttributeInfo intAttribute) {
704 + this.intAttribute = intAttribute;
705 + }
706 +
707 + /**
708 + * Returns attribute for long.
709 + *
710 + * @return attribute for long
711 + */
712 + public JavaAttributeInfo getLongAttribute() {
713 + return longAttribute;
714 + }
715 +
716 + /**
717 + * Sets attribute for long.
718 + *
719 + * @param longAttribute attribute for long
720 + */
721 + private void setLongAttribute(JavaAttributeInfo longAttribute) {
722 + this.longAttribute = longAttribute;
723 + }
724 +
725 + /**
726 + * Returns attribute for uInt.
727 + *
728 + * @return attribute for uInt
729 + */
730 + public JavaAttributeInfo getUIntAttribute() {
731 + return uIntAttribute;
732 + }
733 +
734 + /**
735 + * Sets attribute for uInt.
736 + *
737 + * @param uIntAttribute attribute for uInt
738 + */
739 + private void setUIntAttribute(JavaAttributeInfo uIntAttribute) {
740 + this.uIntAttribute = uIntAttribute;
741 + }
742 +
743 + /**
744 + * Returns attribute for uLong.
745 + *
746 + * @return attribute for uLong
747 + */
748 + public JavaAttributeInfo getULongAttribute() {
749 + return uLongAttribute;
750 + }
751 +
752 + /**
753 + * Sets attribute for uLong.
754 + *
755 + * @param uLongAttribute attribute for uLong
756 + */
757 + private void setULongAttribute(JavaAttributeInfo uLongAttribute) {
758 + this.uLongAttribute = uLongAttribute;
759 + }
353 } 760 }
......
...@@ -147,7 +147,8 @@ public final class YangJavaModelUtils { ...@@ -147,7 +147,8 @@ public final class YangJavaModelUtils {
147 } 147 }
148 } 148 }
149 149
150 - } else if (javaCodeGeneratorInfo instanceof YangLeavesHolder) { 150 + }
151 + if (javaCodeGeneratorInfo instanceof YangLeavesHolder) {
151 /* 152 /*
152 * Container 153 * Container
153 * Case 154 * Case
......
...@@ -36,8 +36,8 @@ import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.gen ...@@ -36,8 +36,8 @@ import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.gen
36 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq; 36 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isGenerationOfCodeReq;
37 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired; 37 import static org.onosproject.yangutils.translator.tojava.YangJavaModelUtils.isManagerCodeGenRequired;
38 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage; 38 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
39 -import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
40 import static org.onosproject.yangutils.utils.UtilConstants.SBI; 39 import static org.onosproject.yangutils.utils.UtilConstants.SBI;
40 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.searchAndDeleteTempDir;
41 41
42 /** 42 /**
43 * Represents module information extended to support java code generation. 43 * Represents module information extended to support java code generation.
...@@ -212,7 +212,7 @@ public class YangJavaModule ...@@ -212,7 +212,7 @@ public class YangJavaModule
212 * @param rootNode root node of the data model 212 * @param rootNode root node of the data model
213 * @return status of rpc's existence 213 * @return status of rpc's existence
214 */ 214 */
215 - public boolean isNotificationChildNodePresent(YangNode rootNode) { 215 + private boolean isNotificationChildNodePresent(YangNode rootNode) {
216 YangNode childNode = rootNode.getChild(); 216 YangNode childNode = rootNode.getChild();
217 217
218 while (childNode != null) { 218 while (childNode != null) {
...@@ -222,9 +222,6 @@ public class YangJavaModule ...@@ -222,9 +222,6 @@ public class YangJavaModule
222 childNode = childNode.getNextSibling(); 222 childNode = childNode.getNextSibling();
223 } 223 }
224 224
225 - if (!getNotificationNodes().isEmpty()) { 225 + return !getNotificationNodes().isEmpty();
226 - return true;
227 - }
228 - return false;
229 } 226 }
230 } 227 }
......
...@@ -194,7 +194,6 @@ public class YangJavaSubModule ...@@ -194,7 +194,6 @@ public class YangJavaSubModule
194 } 194 }
195 } 195 }
196 196
197 -
198 /** 197 /**
199 * Returns notifications node list. 198 * Returns notifications node list.
200 * 199 *
...@@ -219,7 +218,7 @@ public class YangJavaSubModule ...@@ -219,7 +218,7 @@ public class YangJavaSubModule
219 * @param rootNode root node of the data model 218 * @param rootNode root node of the data model
220 * @return status of rpc's existence 219 * @return status of rpc's existence
221 */ 220 */
222 - public boolean isNotificationChildNodePresent(YangNode rootNode) { 221 + private boolean isNotificationChildNodePresent(YangNode rootNode) {
223 YangNode childNode = rootNode.getChild(); 222 YangNode childNode = rootNode.getChild();
224 223
225 while (childNode != null) { 224 while (childNode != null) {
...@@ -229,9 +228,6 @@ public class YangJavaSubModule ...@@ -229,9 +228,6 @@ public class YangJavaSubModule
229 childNode = childNode.getNextSibling(); 228 childNode = childNode.getNextSibling();
230 } 229 }
231 230
232 - if (!getNotificationNodes().isEmpty()) { 231 + return !getNotificationNodes().isEmpty();
233 - return true;
234 - }
235 - return false;
236 } 232 }
237 } 233 }
......
...@@ -182,7 +182,7 @@ public final class ClassDefinitionGenerator { ...@@ -182,7 +182,7 @@ public final class ClassDefinitionGenerator {
182 * @return definition 182 * @return definition
183 */ 183 */
184 private static String getBuilderInterfaceDefinition(String yangName, YangNode curNode) { 184 private static String getBuilderInterfaceDefinition(String yangName, YangNode curNode) {
185 - if (!(curNode instanceof YangCase)) { 185 + if (!(curNode instanceof YangCase) && !(curNode instanceof YangAugment)) {
186 String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_INTERFACE_MASK); 186 String clsDef = getClassDefinitionForWhenExtended(curNode, yangName, BUILDER_INTERFACE_MASK);
187 if (clsDef != null) { 187 if (clsDef != null) {
188 return clsDef; 188 return clsDef;
......
...@@ -42,10 +42,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.HASH_MAP; ...@@ -42,10 +42,14 @@ import static org.onosproject.yangutils.utils.UtilConstants.HASH_MAP;
42 import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE; 42 import static org.onosproject.yangutils.utils.UtilConstants.IMMEDIATE;
43 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT; 43 import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
44 import static org.onosproject.yangutils.utils.UtilConstants.INT; 44 import static org.onosproject.yangutils.utils.UtilConstants.INT;
45 +import static org.onosproject.yangutils.utils.UtilConstants.INT_MAX_RANGE_ATTR;
46 +import static org.onosproject.yangutils.utils.UtilConstants.INT_MIN_RANGE_ATTR;
45 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 47 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
46 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE; 48 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE;
47 import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT; 49 import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_FACTORY_IMPORT;
48 import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT; 50 import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_IMPORT;
51 +import static org.onosproject.yangutils.utils.UtilConstants.LONG_MAX_RANGE_ATTR;
52 +import static org.onosproject.yangutils.utils.UtilConstants.LONG_MIN_RANGE_ATTR;
49 import static org.onosproject.yangutils.utils.UtilConstants.MAP; 53 import static org.onosproject.yangutils.utils.UtilConstants.MAP;
50 import static org.onosproject.yangutils.utils.UtilConstants.NEW; 54 import static org.onosproject.yangutils.utils.UtilConstants.NEW;
51 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 55 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
...@@ -61,6 +65,10 @@ import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_I ...@@ -61,6 +65,10 @@ import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_ANNOTATION_I
61 import static org.onosproject.yangutils.utils.UtilConstants.SPACE; 65 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
62 import static org.onosproject.yangutils.utils.UtilConstants.TRUE; 66 import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
63 import static org.onosproject.yangutils.utils.UtilConstants.TYPE; 67 import static org.onosproject.yangutils.utils.UtilConstants.TYPE;
68 +import static org.onosproject.yangutils.utils.UtilConstants.UINT_MAX_RANGE_ATTR;
69 +import static org.onosproject.yangutils.utils.UtilConstants.UINT_MIN_RANGE_ATTR;
70 +import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MAX_RANGE_ATTR;
71 +import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MIN_RANGE_ATTR;
64 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; 72 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
65 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE; 73 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_ATTRIBUTE;
66 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 74 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
...@@ -97,7 +105,7 @@ public final class JavaCodeSnippetGen { ...@@ -97,7 +105,7 @@ public final class JavaCodeSnippetGen {
97 * @param importInfo import info 105 * @param importInfo import info
98 * @return the textual java code information corresponding to the import list 106 * @return the textual java code information corresponding to the import list
99 */ 107 */
100 - public static String getImportText(JavaQualifiedTypeInfo importInfo) { 108 + static String getImportText(JavaQualifiedTypeInfo importInfo) {
101 return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE; 109 return IMPORT + importInfo.getPkgInfo() + PERIOD + importInfo.getClassInfo() + SEMI_COLAN + NEW_LINE;
102 } 110 }
103 111
...@@ -112,7 +120,8 @@ public final class JavaCodeSnippetGen { ...@@ -112,7 +120,8 @@ public final class JavaCodeSnippetGen {
112 * @return the textual java code for attribute definition in class 120 * @return the textual java code for attribute definition in class
113 */ 121 */
114 public static String getJavaAttributeDefination(String javaAttributeTypePkg, String javaAttributeType, 122 public static String getJavaAttributeDefination(String javaAttributeTypePkg, String javaAttributeType,
115 - String javaAttributeName, boolean isList, String attributeAccessType) { 123 + String javaAttributeName, boolean isList,
124 + String attributeAccessType) {
116 125
117 String attributeDefination = attributeAccessType + SPACE; 126 String attributeDefination = attributeAccessType + SPACE;
118 127
...@@ -209,7 +218,7 @@ public final class JavaCodeSnippetGen { ...@@ -209,7 +218,7 @@ public final class JavaCodeSnippetGen {
209 * 218 *
210 * @return event enum start 219 * @return event enum start
211 */ 220 */
212 - public static String getEventEnumTypeStart() { 221 + static String getEventEnumTypeStart() {
213 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + ENUM + SPACE + TYPE + SPACE + OPEN_CURLY_BRACKET 222 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + ENUM + SPACE + TYPE + SPACE + OPEN_CURLY_BRACKET
214 + NEW_LINE; 223 + NEW_LINE;
215 } 224 }
...@@ -261,7 +270,7 @@ public final class JavaCodeSnippetGen { ...@@ -261,7 +270,7 @@ public final class JavaCodeSnippetGen {
261 * @param className enum's class name 270 * @param className enum's class name
262 * @return enum's attribute 271 * @return enum's attribute
263 */ 272 */
264 - public static String getEnumsValueAttribute(String className) { 273 + static String getEnumsValueAttribute(String className) {
265 return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + INT + SPACE + getSmallCase(className) 274 return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + INT + SPACE + getSmallCase(className)
266 + SEMI_COLAN + NEW_LINE; 275 + SEMI_COLAN + NEW_LINE;
267 } 276 }
...@@ -271,7 +280,7 @@ public final class JavaCodeSnippetGen { ...@@ -271,7 +280,7 @@ public final class JavaCodeSnippetGen {
271 * 280 *
272 * @return component string 281 * @return component string
273 */ 282 */
274 - public static String addComponentString() { 283 + static String addComponentString() {
275 return NEW_LINE + COMPONENT_ANNOTATION + OPEN_PARENTHESIS + IMMEDIATE + SPACE 284 return NEW_LINE + COMPONENT_ANNOTATION + OPEN_PARENTHESIS + IMMEDIATE + SPACE
276 + EQUAL + SPACE + TRUE + CLOSE_PARENTHESIS + NEW_LINE + SERVICE_ANNOTATION; 285 + EQUAL + SPACE + TRUE + CLOSE_PARENTHESIS + NEW_LINE + SERVICE_ANNOTATION;
277 } 286 }
...@@ -281,11 +290,46 @@ public final class JavaCodeSnippetGen { ...@@ -281,11 +290,46 @@ public final class JavaCodeSnippetGen {
281 * 290 *
282 * @return attribute for augmentation 291 * @return attribute for augmentation
283 */ 292 */
284 - public static String addAugmentationAttribute() { 293 + static String addAugmentationAttribute() {
285 return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING 294 return NEW_LINE + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + MAP + DIAMOND_OPEN_BRACKET + CLASS_STRING
286 + DIAMOND_OPEN_BRACKET + QUESTION_MARK + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + YANG_AUGMENTED_INFO 295 + DIAMOND_OPEN_BRACKET + QUESTION_MARK + DIAMOND_CLOSE_BRACKET + COMMA + SPACE + YANG_AUGMENTED_INFO
287 + DIAMOND_CLOSE_BRACKET + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SPACE + EQUAL + SPACE + 296 + DIAMOND_CLOSE_BRACKET + SPACE + getSmallCase(YANG_AUGMENTED_INFO) + MAP + SPACE + EQUAL + SPACE +
288 NEW + SPACE + HASH_MAP + DIAMOND_OPEN_BRACKET + DIAMOND_CLOSE_BRACKET + OPEN_PARENTHESIS 297 NEW + SPACE + HASH_MAP + DIAMOND_OPEN_BRACKET + DIAMOND_CLOSE_BRACKET + OPEN_PARENTHESIS
289 + CLOSE_PARENTHESIS + SEMI_COLAN; 298 + CLOSE_PARENTHESIS + SEMI_COLAN;
290 } 299 }
300 +
301 + /**
302 + * Adds attribute for int ranges.
303 + *
304 + * @param modifier modifier for attribute
305 + * @param addFirst true if int need to be added fist.
306 + * @return attribute for int ranges
307 + */
308 + static String addStaticAttributeIntRange(String modifier, boolean addFirst) {
309 + if (addFirst) {
310 + return NEW_LINE + FOUR_SPACE_INDENTATION + modifier + SPACE + INT_MIN_RANGE_ATTR + FOUR_SPACE_INDENTATION +
311 + modifier +
312 + SPACE + INT_MAX_RANGE_ATTR;
313 + } else {
314 + return NEW_LINE + FOUR_SPACE_INDENTATION + modifier + SPACE + UINT_MIN_RANGE_ATTR + FOUR_SPACE_INDENTATION +
315 + modifier + SPACE + UINT_MAX_RANGE_ATTR;
316 + }
317 + }
318 +
319 + /**
320 + * Adds attribute for long ranges.
321 + *
322 + * @param modifier modifier for attribute
323 + * @param addFirst if need to be added first
324 + * @return attribute for long ranges
325 + */
326 + static String addStaticAttributeLongRange(String modifier, boolean addFirst) {
327 + if (addFirst) {
328 + return NEW_LINE + FOUR_SPACE_INDENTATION + modifier + SPACE + LONG_MIN_RANGE_ATTR + FOUR_SPACE_INDENTATION +
329 + modifier + SPACE + LONG_MAX_RANGE_ATTR;
330 + } else {
331 + return NEW_LINE + FOUR_SPACE_INDENTATION + modifier + SPACE + ULONG_MIN_RANGE_ATTR +
332 + FOUR_SPACE_INDENTATION + modifier + SPACE + ULONG_MAX_RANGE_ATTR;
333 + }
334 + }
291 } 335 }
......
...@@ -28,6 +28,7 @@ import org.onosproject.yangutils.datamodel.YangLeafList; ...@@ -28,6 +28,7 @@ import org.onosproject.yangutils.datamodel.YangLeafList;
28 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 28 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
29 import org.onosproject.yangutils.datamodel.YangModule; 29 import org.onosproject.yangutils.datamodel.YangModule;
30 import org.onosproject.yangutils.datamodel.YangNode; 30 import org.onosproject.yangutils.datamodel.YangNode;
31 +import org.onosproject.yangutils.datamodel.YangSubModule;
31 import org.onosproject.yangutils.datamodel.YangType; 32 import org.onosproject.yangutils.datamodel.YangType;
32 import org.onosproject.yangutils.datamodel.YangTypeDef; 33 import org.onosproject.yangutils.datamodel.YangTypeDef;
33 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; 34 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
...@@ -40,6 +41,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesCont ...@@ -40,6 +41,7 @@ import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesCont
40 import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles; 41 import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles;
41 import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles; 42 import org.onosproject.yangutils.translator.tojava.TempJavaEventFragmentFiles;
42 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles; 43 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
44 +import org.onosproject.yangutils.translator.tojava.TempJavaTypeFragmentFiles;
43 import org.onosproject.yangutils.translator.tojava.YangJavaModelUtils; 45 import org.onosproject.yangutils.translator.tojava.YangJavaModelUtils;
44 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 46 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
45 47
...@@ -121,6 +123,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator ...@@ -121,6 +123,7 @@ import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator
121 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafListgetter; 123 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafListgetter;
122 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafgetter; 124 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafgetter;
123 import static org.onosproject.yangutils.utils.UtilConstants.BASE64; 125 import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
126 +import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
124 import static org.onosproject.yangutils.utils.UtilConstants.BITSET; 127 import static org.onosproject.yangutils.utils.UtilConstants.BITSET;
125 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 128 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
126 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET; 129 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
...@@ -179,6 +182,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase ...@@ -179,6 +182,7 @@ import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase
179 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile; 182 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
180 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast; 183 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
181 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength; 184 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.validateLineLength;
185 +import static java.util.Collections.sort;
182 186
183 /** 187 /**
184 * Representation of java file generator. 188 * Representation of java file generator.
...@@ -205,7 +209,7 @@ public final class JavaFileGenerator { ...@@ -205,7 +209,7 @@ public final class JavaFileGenerator {
205 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo(); 209 JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
206 210
207 String path; 211 String path;
208 - if (curNode instanceof YangModule) { 212 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
209 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); 213 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath();
210 } else { 214 } else {
211 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 215 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
...@@ -216,13 +220,9 @@ public final class JavaFileGenerator { ...@@ -216,13 +220,9 @@ public final class JavaFileGenerator {
216 initiateJavaFileGeneration(file, INTERFACE_MASK, imports, curNode, className); 220 initiateJavaFileGeneration(file, INTERFACE_MASK, imports, curNode, className);
217 221
218 if (isAttrPresent) { 222 if (isAttrPresent) {
219 - /** 223 + // Add getter methods to interface file.
220 - * Add getter methods to interface file.
221 - */
222 try { 224 try {
223 - /** 225 + //Getter methods.
224 - * Getter methods.
225 - */
226 insertDataIntoJavaFile(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, 226 insertDataIntoJavaFile(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK,
227 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 227 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
228 .getBeanTempFiles(), path)); 228 .getBeanTempFiles(), path));
...@@ -251,7 +251,7 @@ public final class JavaFileGenerator { ...@@ -251,7 +251,7 @@ public final class JavaFileGenerator {
251 251
252 String className = getCapitalCase(javaFileInfo.getJavaName()); 252 String className = getCapitalCase(javaFileInfo.getJavaName());
253 String path; 253 String path;
254 - if (curNode instanceof YangModule) { 254 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
255 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); 255 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath();
256 } else { 256 } else {
257 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 257 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
...@@ -261,15 +261,13 @@ public final class JavaFileGenerator { ...@@ -261,15 +261,13 @@ public final class JavaFileGenerator {
261 List<String> methods = new ArrayList<>(); 261 List<String> methods = new ArrayList<>();
262 if (isAttrPresent) { 262 if (isAttrPresent) {
263 try { 263 try {
264 - /** 264 +
265 - * Getter methods. 265 + //Getter methods.
266 - */
267 methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, 266 methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK,
268 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 267 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
269 .getBeanTempFiles(), path)); 268 .getBeanTempFiles(), path));
270 - /** 269 +
271 - * Setter methods. 270 + //Setter methods.
272 - */
273 methods.add(NEW_LINE); 271 methods.add(NEW_LINE);
274 methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK, 272 methods.add(FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK,
275 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 273 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
...@@ -279,16 +277,14 @@ public final class JavaFileGenerator { ...@@ -279,16 +277,14 @@ public final class JavaFileGenerator {
279 + " while builder interface file generation"); 277 + " while builder interface file generation");
280 } 278 }
281 } 279 }
282 - /** 280 +
283 - * Add build method to builder interface file. 281 + //Add build method to builder interface file.
284 - */
285 methods.add( 282 methods.add(
286 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 283 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
287 .addBuildMethodForInterface(pluginConfig)); 284 .addBuildMethodForInterface(pluginConfig));
288 285
289 - /** 286 +
290 - * Add getters and setters in builder interface. 287 + //Add getters and setters in builder interface.
291 - */
292 for (String method : methods) { 288 for (String method : methods) {
293 insertDataIntoJavaFile(file, method); 289 insertDataIntoJavaFile(file, method);
294 } 290 }
...@@ -315,7 +311,7 @@ public final class JavaFileGenerator { ...@@ -315,7 +311,7 @@ public final class JavaFileGenerator {
315 String className = getCapitalCase(javaFileInfo.getJavaName()); 311 String className = getCapitalCase(javaFileInfo.getJavaName());
316 312
317 String path; 313 String path;
318 - if (curNode instanceof YangModule) { 314 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
319 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); 315 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath();
320 } else { 316 } else {
321 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 317 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
...@@ -325,9 +321,8 @@ public final class JavaFileGenerator { ...@@ -325,9 +321,8 @@ public final class JavaFileGenerator {
325 List<String> methods = new ArrayList<>(); 321 List<String> methods = new ArrayList<>();
326 322
327 if (isAttrPresent) { 323 if (isAttrPresent) {
328 - /** 324 +
329 - * Add attribute strings. 325 + //Add attribute strings.
330 - */
331 try { 326 try {
332 insertDataIntoJavaFile(file, 327 insertDataIntoJavaFile(file,
333 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, 328 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK,
...@@ -339,15 +334,11 @@ public final class JavaFileGenerator { ...@@ -339,15 +334,11 @@ public final class JavaFileGenerator {
339 } 334 }
340 335
341 try { 336 try {
342 - /** 337 + //Getter methods.
343 - * Getter methods.
344 - */
345 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, 338 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK,
346 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 339 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
347 .getBeanTempFiles(), path)); 340 .getBeanTempFiles(), path));
348 - /** 341 + // Setter methods.
349 - * Setter methods.
350 - */
351 methods.add(getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK, 342 methods.add(getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK,
352 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 343 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
353 .getBeanTempFiles(), path)); 344 .getBeanTempFiles(), path));
...@@ -360,17 +351,15 @@ public final class JavaFileGenerator { ...@@ -360,17 +351,15 @@ public final class JavaFileGenerator {
360 } else { 351 } else {
361 insertDataIntoJavaFile(file, NEW_LINE); 352 insertDataIntoJavaFile(file, NEW_LINE);
362 } 353 }
363 - /** 354 +
364 - * Add default constructor and build method impl. 355 + // Add default constructor and build method impl.
365 - */
366 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 356 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
367 .addBuildMethodImpl()); 357 .addBuildMethodImpl());
368 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 358 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
369 .addDefaultConstructor(PUBLIC, BUILDER, pluginConfig)); 359 .addDefaultConstructor(PUBLIC, BUILDER, pluginConfig));
370 360
371 - /** 361 +
372 - * Add methods in builder class. 362 + //Add methods in builder class.
373 - */
374 for (String method : methods) { 363 for (String method : methods) {
375 insertDataIntoJavaFile(file, method); 364 insertDataIntoJavaFile(file, method);
376 } 365 }
...@@ -399,9 +388,7 @@ public final class JavaFileGenerator { ...@@ -399,9 +388,7 @@ public final class JavaFileGenerator {
399 List<String> methods = new ArrayList<>(); 388 List<String> methods = new ArrayList<>();
400 389
401 if (isAttrPresent) { 390 if (isAttrPresent) {
402 - /** 391 + //Add attribute strings.
403 - * Add attribute strings.
404 - */
405 try { 392 try {
406 insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE + 393 insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
407 OPERATION_ENUM + SPACE + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE); 394 OPERATION_ENUM + SPACE + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE);
...@@ -448,9 +435,7 @@ public final class JavaFileGenerator { ...@@ -448,9 +435,7 @@ public final class JavaFileGenerator {
448 } 435 }
449 436
450 try { 437 try {
451 - /** 438 + // Setter methods.
452 - * Setter methods.
453 - */
454 methods.add(getSetterForLeaf(className, curNode, pluginConfig)); 439 methods.add(getSetterForLeaf(className, curNode, pluginConfig));
455 methods.add(getSetterForLeafList(className, curNode, pluginConfig)); 440 methods.add(getSetterForLeafList(className, curNode, pluginConfig));
456 441
...@@ -481,9 +466,7 @@ public final class JavaFileGenerator { ...@@ -481,9 +466,7 @@ public final class JavaFileGenerator {
481 insertDataIntoJavaFile(file, NEW_LINE); 466 insertDataIntoJavaFile(file, NEW_LINE);
482 } 467 }
483 468
484 - /** 469 + // Add methods in builder class.
485 - * Add methods in builder class.
486 - */
487 for (String method : methods) { 470 for (String method : methods) {
488 insertDataIntoJavaFile(file, method); 471 insertDataIntoJavaFile(file, method);
489 } 472 }
...@@ -523,14 +506,10 @@ public final class JavaFileGenerator { ...@@ -523,14 +506,10 @@ public final class JavaFileGenerator {
523 JavaAttributeInfo rootAttribute = getCurNodeAsAttributeInTarget(curNode, curNode, false, 506 JavaAttributeInfo rootAttribute = getCurNodeAsAttributeInTarget(curNode, curNode, false,
524 tempJavaServiceFragmentFiles); 507 tempJavaServiceFragmentFiles);
525 try { 508 try {
526 - /** 509 + //Getter methods.
527 - * Getter methods.
528 - */
529 methods.add(getOverRideString() + 510 methods.add(getOverRideString() +
530 getGetterForClass(rootAttribute, GENERATE_SERVICE_AND_MANAGER) + NEW_LINE); 511 getGetterForClass(rootAttribute, GENERATE_SERVICE_AND_MANAGER) + NEW_LINE);
531 - /** 512 + // Setter methods.
532 - * Setter methods.
533 - */
534 methods.add(getOverRideString() + 513 methods.add(getOverRideString() +
535 getSetterForClass(rootAttribute, className, GENERATE_SERVICE_AND_MANAGER) 514 getSetterForClass(rootAttribute, className, GENERATE_SERVICE_AND_MANAGER)
536 + NEW_LINE); 515 + NEW_LINE);
...@@ -538,12 +517,11 @@ public final class JavaFileGenerator { ...@@ -538,12 +517,11 @@ public final class JavaFileGenerator {
538 methods.add(getAugmentsDataMethodForManager(curNode) + NEW_LINE); 517 methods.add(getAugmentsDataMethodForManager(curNode) + NEW_LINE);
539 518
540 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) { 519 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) {
541 - JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; 520 + JavaCodeGeneratorInfo javaGenInfo = (JavaCodeGeneratorInfo) curNode;
542 - /** 521 +
543 - * Rpc methods 522 + //Rpc methods
544 - */
545 methods.add(getDataFromTempFileHandle(RPC_IMPL_MASK, 523 methods.add(getDataFromTempFileHandle(RPC_IMPL_MASK,
546 - javaGeninfo.getTempJavaCodeFragmentFiles().getServiceTempFiles(), path)); 524 + javaGenInfo.getTempJavaCodeFragmentFiles().getServiceTempFiles(), path));
547 } 525 }
548 insertDataIntoJavaFile(file, NEW_LINE); 526 insertDataIntoJavaFile(file, NEW_LINE);
549 527
...@@ -552,9 +530,7 @@ public final class JavaFileGenerator { ...@@ -552,9 +530,7 @@ public final class JavaFileGenerator {
552 + " while manager class file generation"); 530 + " while manager class file generation");
553 } 531 }
554 532
555 - /** 533 + // Add methods in builder class.
556 - * Add methods in builder class.
557 - */
558 for (String method : methods) { 534 for (String method : methods) {
559 insertDataIntoJavaFile(file, method); 535 insertDataIntoJavaFile(file, method);
560 } 536 }
...@@ -579,7 +555,7 @@ public final class JavaFileGenerator { ...@@ -579,7 +555,7 @@ public final class JavaFileGenerator {
579 555
580 String className = getCapitalCase(javaFileInfo.getJavaName()); 556 String className = getCapitalCase(javaFileInfo.getJavaName());
581 String path; 557 String path;
582 - if (curNode instanceof YangModule) { 558 + if (curNode instanceof YangModule || curNode instanceof YangSubModule) {
583 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath(); 559 path = javaFileInfo.getPluginConfig().getCodeGenDir() + javaFileInfo.getPackageFilePath();
584 } else { 560 } else {
585 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 561 path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
...@@ -592,9 +568,8 @@ public final class JavaFileGenerator { ...@@ -592,9 +568,8 @@ public final class JavaFileGenerator {
592 insertDataIntoJavaFile(file, addAugmentationAttribute()); 568 insertDataIntoJavaFile(file, addAugmentationAttribute());
593 } 569 }
594 if (isAttrPresent) { 570 if (isAttrPresent) {
595 - /** 571 +
596 - * Add attribute strings. 572 + //Add attribute strings.
597 - */
598 try { 573 try {
599 insertDataIntoJavaFile(file, 574 insertDataIntoJavaFile(file,
600 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, 575 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK,
...@@ -606,30 +581,25 @@ public final class JavaFileGenerator { ...@@ -606,30 +581,25 @@ public final class JavaFileGenerator {
606 } 581 }
607 582
608 try { 583 try {
609 - /** 584 + //Getter methods.
610 - * Getter methods.
611 - */
612 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, 585 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK,
613 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 586 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
614 .getBeanTempFiles(), path)); 587 .getBeanTempFiles(), path));
615 588
616 - /** 589 +
617 - * Hash code method. 590 + // Hash code method.
618 - */
619 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + 591 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() +
620 getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, 592 getDataFromTempFileHandle(HASH_CODE_IMPL_MASK,
621 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 593 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
622 .getBeanTempFiles(), path).replace(NEW_LINE, EMPTY_STRING))); 594 .getBeanTempFiles(), path).replace(NEW_LINE, EMPTY_STRING)));
623 - /** 595 +
624 - * Equals method. 596 + //Equals method.
625 - */
626 methods.add(getEqualsMethodClose(getEqualsMethodOpen(getCapitalCase(DEFAULT) + className) 597 methods.add(getEqualsMethodClose(getEqualsMethodOpen(getCapitalCase(DEFAULT) + className)
627 + getDataFromTempFileHandle(EQUALS_IMPL_MASK, 598 + getDataFromTempFileHandle(EQUALS_IMPL_MASK,
628 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 599 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
629 .getBeanTempFiles(), path))); 600 .getBeanTempFiles(), path)));
630 - /** 601 +
631 - * To string method. 602 + // To string method.
632 - */
633 methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, 603 methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK,
634 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 604 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
635 .getBeanTempFiles(), path) 605 .getBeanTempFiles(), path)
...@@ -644,9 +614,7 @@ public final class JavaFileGenerator { ...@@ -644,9 +614,7 @@ public final class JavaFileGenerator {
644 } 614 }
645 try { 615 try {
646 616
647 - /** 617 + //Constructor.
648 - * Constructor.
649 - */
650 String constructor = getConstructorStart(className, pluginConfig); 618 String constructor = getConstructorStart(className, pluginConfig);
651 constructor = constructor + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK, 619 constructor = constructor + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK,
652 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 620 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
...@@ -664,9 +632,7 @@ public final class JavaFileGenerator { ...@@ -664,9 +632,7 @@ public final class JavaFileGenerator {
664 methods.add(getAugmentInfoMapImpl(javaFileInfo.getPluginConfig())); 632 methods.add(getAugmentInfoMapImpl(javaFileInfo.getPluginConfig()));
665 } 633 }
666 634
667 - /** 635 + // Add methods in impl class.
668 - * Add methods in impl class.
669 - */
670 for (String method : methods) { 636 for (String method : methods) {
671 insertDataIntoJavaFile(file, method); 637 insertDataIntoJavaFile(file, method);
672 } 638 }
...@@ -698,9 +664,8 @@ public final class JavaFileGenerator { ...@@ -698,9 +664,8 @@ public final class JavaFileGenerator {
698 List<String> methods = new ArrayList<>(); 664 List<String> methods = new ArrayList<>();
699 665
700 if (isAttrPresent) { 666 if (isAttrPresent) {
701 - /** 667 +
702 - * Add attribute strings. 668 + // Add attribute strings.
703 - */
704 try { 669 try {
705 insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC + 670 insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PUBLIC + SPACE + STATIC +
706 SPACE + ENUM + SPACE + OPERATION_ENUM + SPACE + OPEN_CURLY_BRACKET + 671 SPACE + ENUM + SPACE + OPERATION_ENUM + SPACE + OPEN_CURLY_BRACKET +
...@@ -716,9 +681,8 @@ public final class JavaFileGenerator { ...@@ -716,9 +681,8 @@ public final class JavaFileGenerator {
716 + " while impl class file generation"); 681 + " while impl class file generation");
717 } 682 }
718 683
719 - /** 684 +
720 - * Add attribute strings. 685 + // Add attribute strings.
721 - */
722 try { 686 try {
723 insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE + 687 insertDataIntoJavaFile(file, FOUR_SPACE_INDENTATION + PRIVATE + SPACE +
724 OPERATION_ENUM + SPACE + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE); 688 OPERATION_ENUM + SPACE + OP_PARAM_TYPE + SEMI_COLAN + NEW_LINE);
...@@ -822,9 +786,7 @@ public final class JavaFileGenerator { ...@@ -822,9 +786,7 @@ public final class JavaFileGenerator {
822 methods.add(getBaseClassMethodImpl(clsName)); 786 methods.add(getBaseClassMethodImpl(clsName));
823 } 787 }
824 788
825 - /** 789 + // Add methods in impl class.
826 - * Add methods in impl class.
827 - */
828 for (String method : methods) { 790 for (String method : methods) {
829 insertDataIntoJavaFile(file, method); 791 insertDataIntoJavaFile(file, method);
830 } 792 }
...@@ -862,9 +824,8 @@ public final class JavaFileGenerator { ...@@ -862,9 +824,8 @@ public final class JavaFileGenerator {
862 824
863 List<String> methods = new ArrayList<>(); 825 List<String> methods = new ArrayList<>();
864 826
865 - /** 827 +
866 - * Add attribute strings. 828 + //Add attribute strings.
867 - */
868 try { 829 try {
869 insertDataIntoJavaFile(file, 830 insertDataIntoJavaFile(file,
870 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, 831 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK,
...@@ -875,55 +836,47 @@ public final class JavaFileGenerator { ...@@ -875,55 +836,47 @@ public final class JavaFileGenerator {
875 + " while type def class file generation"); 836 + " while type def class file generation");
876 } 837 }
877 838
878 - /** 839 +
879 - * Default constructor. 840 + //Default constructor.
880 - */
881 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 841 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
882 .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig)); 842 .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig));
883 843
884 try { 844 try {
885 845
886 - /** 846 +
887 - * Type constructor. 847 + //Type constructor.
888 - */
889 methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK, 848 methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK,
890 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 849 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
891 path)); 850 path));
892 851
893 - /** 852 +
894 - * Of method. 853 + //Of method.
895 - */
896 methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK, 854 methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK,
897 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 855 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
898 path)); 856 path));
899 857
900 - /** 858 + //Getter methods.
901 - * Getter method.
902 - */
903 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, 859 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK,
904 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 860 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
905 path)); 861 path));
906 862
907 - /** 863 +
908 - * Hash code method. 864 + // Hash code method.
909 - */
910 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + 865 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() +
911 getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, 866 getDataFromTempFileHandle(HASH_CODE_IMPL_MASK,
912 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 867 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
913 .getTypeTempFiles(), path) 868 .getTypeTempFiles(), path)
914 .replace(NEW_LINE, EMPTY_STRING))); 869 .replace(NEW_LINE, EMPTY_STRING)));
915 870
916 - /** 871 +
917 - * Equals method. 872 + //Equals method.
918 - */
919 methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING) 873 methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING)
920 + getDataFromTempFileHandle(EQUALS_IMPL_MASK, 874 + getDataFromTempFileHandle(EQUALS_IMPL_MASK,
921 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 875 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
922 .getTypeTempFiles(), path))); 876 .getTypeTempFiles(), path)));
923 877
924 - /** 878 +
925 - * To string method. 879 + //To string method.
926 - */
927 if (type.getDataType().equals(YangDataTypes.BINARY)) { 880 if (type.getDataType().equals(YangDataTypes.BINARY)) {
928 JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode, 881 JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
929 getCapitalCase("binary")); 882 getCapitalCase("binary"));
...@@ -953,16 +906,15 @@ public final class JavaFileGenerator { ...@@ -953,16 +906,15 @@ public final class JavaFileGenerator {
953 methods.add(bitsToStringMethod); 906 methods.add(bitsToStringMethod);
954 } else { 907 } else {
955 methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, 908 methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK,
956 - ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 909 + ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
957 - path) + getToStringMethodClose()); 910 + .getTypeTempFiles(), path) + getToStringMethodClose());
958 } 911 }
959 912
960 - JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; 913 + JavaCodeGeneratorInfo javaGenInfo = (JavaCodeGeneratorInfo) curNode;
961 - /** 914 +
962 - * From string method. 915 + //From string method.
963 - */
964 methods.add(getFromStringMethodSignature(className, pluginConfig) 916 methods.add(getFromStringMethodSignature(className, pluginConfig)
965 - + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, javaGeninfo.getTempJavaCodeFragmentFiles() 917 + + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, javaGenInfo.getTempJavaCodeFragmentFiles()
966 .getTypeTempFiles(), path) 918 .getTypeTempFiles(), path)
967 + getFromStringMethodClose()); 919 + getFromStringMethodClose());
968 920
...@@ -997,14 +949,50 @@ public final class JavaFileGenerator { ...@@ -997,14 +949,50 @@ public final class JavaFileGenerator {
997 String className = getCapitalCase(javaFileInfo.getJavaName()); 949 String className = getCapitalCase(javaFileInfo.getJavaName());
998 String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 950 String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
999 951
952 + TempJavaTypeFragmentFiles tempJavaTypeFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
953 + .getTempJavaCodeFragmentFiles().getTypeTempFiles();
954 +
955 + boolean isIntConflict = false;
956 + boolean isLongConflict = false;
957 + JavaAttributeInfo intAttr = tempJavaTypeFragmentFiles.getIntAttribute();
958 + if (intAttr == null) {
959 + intAttr = tempJavaTypeFragmentFiles.getUIntAttribute();
960 + }
961 +
962 + JavaAttributeInfo longAttr = tempJavaTypeFragmentFiles.getLongAttribute();
963 + if (longAttr == null) {
964 + longAttr = tempJavaTypeFragmentFiles.getULongAttribute();
965 + }
966 +
967 + if (intAttr != null) {
968 + isIntConflict = intAttr.isIntConflict();
969 + }
970 + if (longAttr != null) {
971 + isLongConflict = longAttr.isLongConflict();
972 + }
973 +
974 + if (isLongConflict) {
975 + imports.add(tempJavaTypeFragmentFiles.getJavaImportData().getBigIntegerImport());
976 + sort(imports);
977 + }
978 +
1000 initiateJavaFileGeneration(file, className, GENERATE_UNION_CLASS, imports, path, pluginConfig); 979 initiateJavaFileGeneration(file, className, GENERATE_UNION_CLASS, imports, path, pluginConfig);
1001 980
1002 List<String> methods = new ArrayList<>(); 981 List<String> methods = new ArrayList<>();
1003 982
1004 - /** 983 +
1005 - * Add attribute strings. 984 + // Add attribute strings.
1006 - */
1007 try { 985 try {
986 + if (isIntConflict) {
987 + insertDataIntoJavaFile(file, JavaCodeSnippetGen.addStaticAttributeIntRange(PRIVATE,
988 + tempJavaTypeFragmentFiles.getIntIndex() < tempJavaTypeFragmentFiles.getUIntIndex()));
989 + }
990 +
991 + if (isLongConflict) {
992 + insertDataIntoJavaFile(file, JavaCodeSnippetGen.addStaticAttributeLongRange(PRIVATE,
993 + tempJavaTypeFragmentFiles.getLongIndex() < tempJavaTypeFragmentFiles.getULongIndex()));
994 + }
995 +
1008 insertDataIntoJavaFile(file, 996 insertDataIntoJavaFile(file,
1009 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK, 997 NEW_LINE + FOUR_SPACE_INDENTATION + getDataFromTempFileHandle(ATTRIBUTES_MASK,
1010 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 998 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
...@@ -1014,70 +1002,67 @@ public final class JavaFileGenerator { ...@@ -1014,70 +1002,67 @@ public final class JavaFileGenerator {
1014 + " while union class file generation"); 1002 + " while union class file generation");
1015 } 1003 }
1016 1004
1017 - /** 1005 +
1018 - * Default constructor. 1006 + //Default constructor.
1019 - */
1020 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 1007 methods.add(((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
1021 .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig)); 1008 .addDefaultConstructor(PRIVATE, EMPTY_STRING, pluginConfig));
1022 1009
1023 try { 1010 try {
1024 1011
1025 - /** 1012 +
1026 - * Type constructor. 1013 + //Type constructor.
1027 - */
1028 methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK, 1014 methods.add(getDataFromTempFileHandle(CONSTRUCTOR_FOR_TYPE_MASK,
1029 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 1015 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
1030 path)); 1016 path));
1031 1017
1032 - /** 1018 +
1033 - * Of string method. 1019 + // Of string method.
1034 - */
1035 methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK, 1020 methods.add(getDataFromTempFileHandle(OF_STRING_IMPL_MASK,
1036 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 1021 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
1037 path)); 1022 path));
1038 1023
1039 - /** 1024 + //Getter methods.
1040 - * Getter method.
1041 - */
1042 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, 1025 methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK,
1043 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(), 1026 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
1044 path)); 1027 path));
1045 1028
1046 - /** 1029 +
1047 - * Hash code method. 1030 + //Hash code method.
1048 - */
1049 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + 1031 methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() +
1050 getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, 1032 getDataFromTempFileHandle(HASH_CODE_IMPL_MASK,
1051 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 1033 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
1052 .getTypeTempFiles(), path) 1034 .getTypeTempFiles(), path)
1053 .replace(NEW_LINE, EMPTY_STRING))); 1035 .replace(NEW_LINE, EMPTY_STRING)));
1054 1036
1055 - /** 1037 + //Equals method.
1056 - * Equals method.
1057 - */
1058 methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING) 1038 methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + EMPTY_STRING)
1059 + getDataFromTempFileHandle(EQUALS_IMPL_MASK, 1039 + getDataFromTempFileHandle(EQUALS_IMPL_MASK,
1060 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 1040 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
1061 .getTypeTempFiles(), path))); 1041 .getTypeTempFiles(), path)));
1062 1042
1063 - /** 1043 +
1064 - * To string method. 1044 + //To string method.
1065 - */
1066 methods.add(getToStringMethodOpen() + getOmitNullValueString() + 1045 methods.add(getToStringMethodOpen() + getOmitNullValueString() +
1067 getDataFromTempFileHandle(TO_STRING_IMPL_MASK, 1046 getDataFromTempFileHandle(TO_STRING_IMPL_MASK,
1068 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 1047 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
1069 .getTypeTempFiles(), path) 1048 .getTypeTempFiles(), path)
1070 + getToStringMethodClose()); 1049 + getToStringMethodClose());
1071 1050
1072 - /** 1051 +
1073 - * From string method. 1052 + //From string method.
1074 - */
1075 methods.add(getFromStringMethodSignature(className, pluginConfig) 1053 methods.add(getFromStringMethodSignature(className, pluginConfig)
1076 + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, 1054 + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK,
1077 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles() 1055 ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles()
1078 .getTypeTempFiles(), path) 1056 .getTypeTempFiles(), path)
1079 + getFromStringMethodClose()); 1057 + getFromStringMethodClose());
1080 1058
1059 + if (isIntConflict) {
1060 + methods.add(MethodsGenerator.getRangeValidatorMethodForUnion(INT));
1061 + }
1062 + if (isLongConflict) {
1063 + methods.add(MethodsGenerator.getRangeValidatorMethodForUnion(BIG_INTEGER));
1064 + }
1065 +
1081 } catch (IOException e) { 1066 } catch (IOException e) {
1082 throw new IOException("No data found in temporary java code fragment files for " + className 1067 throw new IOException("No data found in temporary java code fragment files for " + className
1083 + " while union class file generation"); 1068 + " while union class file generation");
...@@ -1109,13 +1094,12 @@ public final class JavaFileGenerator { ...@@ -1109,13 +1094,12 @@ public final class JavaFileGenerator {
1109 String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath(); 1094 String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
1110 1095
1111 initiateJavaFileGeneration(file, getCapitalCase(className), GENERATE_ENUM_CLASS, null, path, pluginConfig); 1096 initiateJavaFileGeneration(file, getCapitalCase(className), GENERATE_ENUM_CLASS, null, path, pluginConfig);
1112 - /** 1097 +
1113 - * Add attribute strings. 1098 + //Add attribute strings.
1114 - */
1115 try { 1099 try {
1116 - JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; 1100 + JavaCodeGeneratorInfo javaGenInfo = (JavaCodeGeneratorInfo) curNode;
1117 insertDataIntoJavaFile(file, 1101 insertDataIntoJavaFile(file,
1118 - trimAtLast(trimAtLast(getDataFromTempFileHandle(ENUM_IMPL_MASK, javaGeninfo 1102 + trimAtLast(trimAtLast(getDataFromTempFileHandle(ENUM_IMPL_MASK, javaGenInfo
1119 .getTempJavaCodeFragmentFiles().getEnumerationTempFiles(), path), COMMA), NEW_LINE) 1103 .getTempJavaCodeFragmentFiles().getEnumerationTempFiles(), path), COMMA), NEW_LINE)
1120 + SEMI_COLAN + NEW_LINE); 1104 + SEMI_COLAN + NEW_LINE);
1121 } catch (IOException e) { 1105 } catch (IOException e) {
...@@ -1123,15 +1107,11 @@ public final class JavaFileGenerator { ...@@ -1123,15 +1107,11 @@ public final class JavaFileGenerator {
1123 + " while enum class file generation"); 1107 + " while enum class file generation");
1124 } 1108 }
1125 1109
1126 - /** 1110 +
1127 - * Add an 1111 + // Add an attribute to get the enum's values.
1128 - * attribute to get the enum's values.
1129 - */
1130 insertDataIntoJavaFile(file, getEnumsValueAttribute(getCapitalCase(className))); 1112 insertDataIntoJavaFile(file, getEnumsValueAttribute(getCapitalCase(className)));
1131 1113
1132 - /** 1114 + // Add a constructor for enum.
1133 - * Add a constructor for enum.
1134 - */
1135 insertDataIntoJavaFile(file, getJavaDoc(TYPE_CONSTRUCTOR, className, false, pluginConfig) 1115 insertDataIntoJavaFile(file, getJavaDoc(TYPE_CONSTRUCTOR, className, false, pluginConfig)
1136 + getEnumsConstructor(getCapitalCase(className)) + NEW_LINE); 1116 + getEnumsConstructor(getCapitalCase(className)) + NEW_LINE);
1137 1117
...@@ -1144,9 +1124,7 @@ public final class JavaFileGenerator { ...@@ -1144,9 +1124,7 @@ public final class JavaFileGenerator {
1144 enumFragFiles.getEnumStringList(), pluginConfig) 1124 enumFragFiles.getEnumStringList(), pluginConfig)
1145 + NEW_LINE); 1125 + NEW_LINE);
1146 1126
1147 - /** 1127 + // Add a getter method for enum.
1148 - * Add a getter method for enum.
1149 - */
1150 insertDataIntoJavaFile(file, getJavaDoc(GETTER_METHOD, className, false, pluginConfig) 1128 insertDataIntoJavaFile(file, getJavaDoc(GETTER_METHOD, className, false, pluginConfig)
1151 + getGetter(INT, className, GENERATE_ENUM_CLASS) + NEW_LINE); 1129 + getGetter(INT, className, GENERATE_ENUM_CLASS) + NEW_LINE);
1152 1130
...@@ -1191,26 +1169,22 @@ public final class JavaFileGenerator { ...@@ -1191,26 +1169,22 @@ public final class JavaFileGenerator {
1191 tempJavaServiceFragmentFiles); 1169 tempJavaServiceFragmentFiles);
1192 1170
1193 try { 1171 try {
1194 - /** 1172 +
1195 - * Getter methods. 1173 + //Getter methods.
1196 - */
1197 methods.add(getGetterString(rootAttribute, GENERATE_SERVICE_AND_MANAGER, 1174 methods.add(getGetterString(rootAttribute, GENERATE_SERVICE_AND_MANAGER,
1198 javaFileInfo.getPluginConfig()) + NEW_LINE); 1175 javaFileInfo.getPluginConfig()) + NEW_LINE);
1199 - /** 1176 + // Setter methods.
1200 - * Setter methods.
1201 - */
1202 methods.add(getSetterString(rootAttribute, className, GENERATE_SERVICE_AND_MANAGER, 1177 methods.add(getSetterString(rootAttribute, className, GENERATE_SERVICE_AND_MANAGER,
1203 javaFileInfo.getPluginConfig()) + NEW_LINE); 1178 javaFileInfo.getPluginConfig()) + NEW_LINE);
1204 1179
1205 methods.add(getAugmentsDataMethodForService(curNode) + NEW_LINE); 1180 methods.add(getAugmentsDataMethodForService(curNode) + NEW_LINE);
1206 1181
1207 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) { 1182 if (((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles() != null) {
1208 - JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode; 1183 + JavaCodeGeneratorInfo javaGenInfo = (JavaCodeGeneratorInfo) curNode;
1209 - /** 1184 +
1210 - * Rpc methods 1185 + // Rpc methods
1211 - */
1212 methods.add(getDataFromTempFileHandle(RPC_INTERFACE_MASK, 1186 methods.add(getDataFromTempFileHandle(RPC_INTERFACE_MASK,
1213 - javaGeninfo.getTempJavaCodeFragmentFiles().getServiceTempFiles(), path)); 1187 + javaGenInfo.getTempJavaCodeFragmentFiles().getServiceTempFiles(), path));
1214 } 1188 }
1215 } catch (IOException e) { 1189 } catch (IOException e) {
1216 throw new IOException("No data found in temporary java code fragment files for " + className 1190 throw new IOException("No data found in temporary java code fragment files for " + className
......
...@@ -57,7 +57,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType. ...@@ -57,7 +57,6 @@ import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.
57 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK; 57 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_BUILDER_CLASS_MASK;
58 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_CLASS_MASK; 58 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.OPERATION_CLASS_MASK;
59 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK; 59 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
60 -import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.AUGMENTE_CLASS_CONSTRUCTOR_MASK;
61 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK; 60 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_FOR_TYPE_MASK;
62 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK; 61 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
63 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK; 62 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK;
...@@ -205,10 +204,6 @@ public final class JavaFileGeneratorUtils { ...@@ -205,10 +204,6 @@ public final class JavaFileGeneratorUtils {
205 return tempJavaFragmentFiles 204 return tempJavaFragmentFiles
206 .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getToStringImplTempFileHandle(), 205 .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getToStringImplTempFileHandle(),
207 absolutePath); 206 absolutePath);
208 - } else if ((generatedTempFiles & AUGMENTE_CLASS_CONSTRUCTOR_MASK) != 0) {
209 - return tempJavaFragmentFiles
210 - .getTemporaryDataFromFileHandle(tempJavaFragmentFiles.getAugmentConstructorImplTempFileHandle(),
211 - absolutePath);
212 } else if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) { 207 } else if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) {
213 if (typeFragmentFiles == null) { 208 if (typeFragmentFiles == null) {
214 throw new TranslatorException("Required of string implementation info is missing."); 209 throw new TranslatorException("Required of string implementation info is missing.");
......
...@@ -23,6 +23,7 @@ import org.onosproject.yangutils.datamodel.YangAtomicPath; ...@@ -23,6 +23,7 @@ import org.onosproject.yangutils.datamodel.YangAtomicPath;
23 import org.onosproject.yangutils.datamodel.YangAugmentableNode; 23 import org.onosproject.yangutils.datamodel.YangAugmentableNode;
24 import org.onosproject.yangutils.datamodel.YangLeaf; 24 import org.onosproject.yangutils.datamodel.YangLeaf;
25 import org.onosproject.yangutils.datamodel.YangLeafList; 25 import org.onosproject.yangutils.datamodel.YangLeafList;
26 +import org.onosproject.yangutils.datamodel.YangLeafRef;
26 import org.onosproject.yangutils.datamodel.YangLeavesHolder; 27 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
27 import org.onosproject.yangutils.datamodel.YangNode; 28 import org.onosproject.yangutils.datamodel.YangNode;
28 import org.onosproject.yangutils.datamodel.YangType; 29 import org.onosproject.yangutils.datamodel.YangType;
...@@ -44,6 +45,7 @@ import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangData ...@@ -44,6 +45,7 @@ import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangData
44 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32; 45 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT32;
45 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64; 46 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT64;
46 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT8; 47 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.INT8;
48 +import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.LEAFREF;
47 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16; 49 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT16;
48 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32; 50 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT32;
49 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT64; 51 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.UINT64;
...@@ -55,8 +57,10 @@ import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles. ...@@ -55,8 +57,10 @@ import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.
55 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentedClassNameForDataMethods; 57 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getAugmentedClassNameForDataMethods;
56 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods; 58 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getParentNodeNameForDataMethods;
57 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers; 59 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getSetOfNodeIdentifiers;
60 +import static org.onosproject.yangutils.translator.tojava.utils.ValidatorTypeForUnionTypes.INT_TYPE_CONFLICT;
58 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE; 61 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE;
59 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION; 62 import static org.onosproject.yangutils.utils.UtilConstants.ACTIVATE_ANNOTATION;
63 +import static org.onosproject.yangutils.utils.UtilConstants.ADD;
60 import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING; 64 import static org.onosproject.yangutils.utils.UtilConstants.ADD_STRING;
61 import static org.onosproject.yangutils.utils.UtilConstants.AND; 65 import static org.onosproject.yangutils.utils.UtilConstants.AND;
62 import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE; 66 import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE;
...@@ -91,6 +95,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKE ...@@ -91,6 +95,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKE
91 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET; 95 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET;
92 import static org.onosproject.yangutils.utils.UtilConstants.DOUBLE; 96 import static org.onosproject.yangutils.utils.UtilConstants.DOUBLE;
93 import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION; 97 import static org.onosproject.yangutils.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
98 +import static org.onosproject.yangutils.utils.UtilConstants.ELSE;
94 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING; 99 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
95 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL; 100 import static org.onosproject.yangutils.utils.UtilConstants.EQUAL;
96 import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING; 101 import static org.onosproject.yangutils.utils.UtilConstants.EQUALS_STRING;
...@@ -121,10 +126,16 @@ import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ARGUMENT_EXC ...@@ -121,10 +126,16 @@ import static org.onosproject.yangutils.utils.UtilConstants.ILLEGAL_ARGUMENT_EXC
121 import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF; 126 import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_OF;
122 import static org.onosproject.yangutils.utils.UtilConstants.INT; 127 import static org.onosproject.yangutils.utils.UtilConstants.INT;
123 import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER; 128 import static org.onosproject.yangutils.utils.UtilConstants.INTEGER_WRAPPER;
129 +import static org.onosproject.yangutils.utils.UtilConstants.INT_MAX_RANGE;
130 +import static org.onosproject.yangutils.utils.UtilConstants.INT_MIN_RANGE;
124 import static org.onosproject.yangutils.utils.UtilConstants.LIST; 131 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
125 import static org.onosproject.yangutils.utils.UtilConstants.LONG; 132 import static org.onosproject.yangutils.utils.UtilConstants.LONG;
133 +import static org.onosproject.yangutils.utils.UtilConstants.LONG_MAX_RANGE;
134 +import static org.onosproject.yangutils.utils.UtilConstants.LONG_MIN_RANGE;
126 import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER; 135 import static org.onosproject.yangutils.utils.UtilConstants.LONG_WRAPPER;
127 import static org.onosproject.yangutils.utils.UtilConstants.MAP; 136 import static org.onosproject.yangutils.utils.UtilConstants.MAP;
137 +import static org.onosproject.yangutils.utils.UtilConstants.MAX_RANGE;
138 +import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE;
128 import static org.onosproject.yangutils.utils.UtilConstants.NEW; 139 import static org.onosproject.yangutils.utils.UtilConstants.NEW;
129 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE; 140 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
130 import static org.onosproject.yangutils.utils.UtilConstants.NOT; 141 import static org.onosproject.yangutils.utils.UtilConstants.NOT;
...@@ -148,6 +159,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.PARSE_INT; ...@@ -148,6 +159,7 @@ import static org.onosproject.yangutils.utils.UtilConstants.PARSE_INT;
148 import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG; 159 import static org.onosproject.yangutils.utils.UtilConstants.PARSE_LONG;
149 import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT; 160 import static org.onosproject.yangutils.utils.UtilConstants.PARSE_SHORT;
150 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD; 161 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
162 +import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
151 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC; 163 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
152 import static org.onosproject.yangutils.utils.UtilConstants.PUT; 164 import static org.onosproject.yangutils.utils.UtilConstants.PUT;
153 import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK; 165 import static org.onosproject.yangutils.utils.UtilConstants.QUESTION_MARK;
...@@ -182,6 +194,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING; ...@@ -182,6 +194,11 @@ import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING;
182 import static org.onosproject.yangutils.utils.UtilConstants.TRUE; 194 import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
183 import static org.onosproject.yangutils.utils.UtilConstants.TRY; 195 import static org.onosproject.yangutils.utils.UtilConstants.TRY;
184 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION; 196 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
197 +import static org.onosproject.yangutils.utils.UtilConstants.UINT_MAX_RANGE;
198 +import static org.onosproject.yangutils.utils.UtilConstants.UINT_MIN_RANGE;
199 +import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MAX_RANGE;
200 +import static org.onosproject.yangutils.utils.UtilConstants.ULONG_MIN_RANGE;
201 +import static org.onosproject.yangutils.utils.UtilConstants.VALIDATE_RANGE;
185 import static org.onosproject.yangutils.utils.UtilConstants.VALUE; 202 import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
186 import static org.onosproject.yangutils.utils.UtilConstants.VOID; 203 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
187 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; 204 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
...@@ -199,6 +216,7 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SET ...@@ -199,6 +216,7 @@ import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SET
199 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR; 216 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
200 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForAddAugmentation; 217 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForAddAugmentation;
201 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetAugmentation; 218 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForGetAugmentation;
219 +import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateForValidatorMethod;
202 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc; 220 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
203 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase; 221 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCamelCase;
204 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase; 222 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
...@@ -262,7 +280,7 @@ public final class MethodsGenerator { ...@@ -262,7 +280,7 @@ public final class MethodsGenerator {
262 String attrType = getReturnType(attr); 280 String attrType = getReturnType(attr);
263 String attributeName = attr.getAttributeName(); 281 String attributeName = attr.getAttributeName();
264 JavaDocGen.JavaDocType type; 282 JavaDocGen.JavaDocType type;
265 - if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { 283 + if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
266 type = MANAGER_SETTER_METHOD; 284 type = MANAGER_SETTER_METHOD;
267 } else { 285 } else {
268 type = SETTER_METHOD; 286 type = SETTER_METHOD;
...@@ -348,7 +366,7 @@ public final class MethodsGenerator { ...@@ -348,7 +366,7 @@ public final class MethodsGenerator {
348 */ 366 */
349 public static String getGetter(String type, String name, int generatedJavaFiles) { 367 public static String getGetter(String type, String name, int generatedJavaFiles) {
350 String ret = parseTypeForReturnValue(type); 368 String ret = parseTypeForReturnValue(type);
351 - if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { 369 + if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
352 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + type + SPACE + GET_METHOD_PREFIX + getCapitalCase(name) 370 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + type + SPACE + GET_METHOD_PREFIX + getCapitalCase(name)
353 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + 371 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE +
354 EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO + NEW_LINE + EIGHT_SPACE_INDENTATION + 372 EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO + NEW_LINE + EIGHT_SPACE_INDENTATION +
...@@ -406,7 +424,7 @@ public final class MethodsGenerator { ...@@ -406,7 +424,7 @@ public final class MethodsGenerator {
406 * @return setter for attribute 424 * @return setter for attribute
407 */ 425 */
408 private static String getSetter(String className, String name, String type, int generatedJavaFiles) { 426 private static String getSetter(String className, String name, String type, int generatedJavaFiles) {
409 - if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { 427 + if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
410 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX 428 return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + VOID + SPACE + SET_METHOD_PREFIX
411 + getCapitalCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE + 429 + getCapitalCase(name) + OPEN_PARENTHESIS + type + SPACE + name + CLOSE_PARENTHESIS + SPACE +
412 OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO + 430 OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION + YANG_UTILS_TODO +
...@@ -489,7 +507,7 @@ public final class MethodsGenerator { ...@@ -489,7 +507,7 @@ public final class MethodsGenerator {
489 */ 507 */
490 private static String getGetterInterfaceString(String returnType, String yangName, 508 private static String getGetterInterfaceString(String returnType, String yangName,
491 int generatedJavaFiles) { 509 int generatedJavaFiles) {
492 - if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { 510 + if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
493 return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName) 511 return FOUR_SPACE_INDENTATION + returnType + SPACE + GET_METHOD_PREFIX + getCapitalCase(yangName)
494 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN; 512 + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN;
495 } else { 513 } else {
...@@ -528,7 +546,7 @@ public final class MethodsGenerator { ...@@ -528,7 +546,7 @@ public final class MethodsGenerator {
528 */ 546 */
529 private static String getSetterInterfaceString(String className, String attrName, String attrType, 547 private static String getSetterInterfaceString(String className, String attrName, String attrType,
530 int generatedJavaFiles) { 548 int generatedJavaFiles) {
531 - if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { 549 + if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
532 550
533 return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName) 551 return FOUR_SPACE_INDENTATION + VOID + SPACE + SET_METHOD_PREFIX + getCapitalCase(attrName)
534 + OPEN_PARENTHESIS + attrType + SPACE + attrName + CLOSE_PARENTHESIS + SEMI_COLAN; 552 + OPEN_PARENTHESIS + attrType + SPACE + attrName + CLOSE_PARENTHESIS + SEMI_COLAN;
...@@ -620,7 +638,7 @@ public final class MethodsGenerator { ...@@ -620,7 +638,7 @@ public final class MethodsGenerator {
620 String attributeName = attr.getAttributeName(); 638 String attributeName = attr.getAttributeName();
621 String constructor; 639 String constructor;
622 640
623 - if ((generatedJavaFiles & GENERATE_SERVICE_AND_MANAGER) != 0) { 641 + if (generatedJavaFiles == GENERATE_SERVICE_AND_MANAGER) {
624 constructor = EIGHT_SPACE_INDENTATION + THIS + PERIOD 642 constructor = EIGHT_SPACE_INDENTATION + THIS + PERIOD
625 + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + SPACE + EQUAL 643 + getCamelCase(attributeName, pluginConfig.getConflictResolver()) + SPACE + EQUAL
626 + SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_METHOD_PREFIX 644 + SPACE + BUILDER.toLowerCase() + OBJECT + PERIOD + GET_METHOD_PREFIX
...@@ -884,7 +902,7 @@ public final class MethodsGenerator { ...@@ -884,7 +902,7 @@ public final class MethodsGenerator {
884 * @param dataType data type to be checked 902 * @param dataType data type to be checked
885 * @return true, if data type can have primitive data type, false otherwise 903 * @return true, if data type can have primitive data type, false otherwise
886 */ 904 */
887 - public static boolean isPrimitiveDataType(YangDataTypes dataType) { 905 + private static boolean isPrimitiveDataType(YangDataTypes dataType) {
888 return dataType == INT8 906 return dataType == INT8
889 || dataType == INT16 907 || dataType == INT16
890 || dataType == INT32 908 || dataType == INT32
...@@ -896,6 +914,42 @@ public final class MethodsGenerator { ...@@ -896,6 +914,42 @@ public final class MethodsGenerator {
896 || dataType == DECIMAL64 914 || dataType == DECIMAL64
897 || dataType == BOOLEAN 915 || dataType == BOOLEAN
898 || dataType == EMPTY; 916 || dataType == EMPTY;
917 +
918 + }
919 +
920 + private static String getAttrTypeForFilterContentMatchWhenPrimitiveDataType(String attributeName) {
921 + return APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
922 + + SPACE + NOT + EQUAL + SPACE + attributeName + OPEN_PARENTHESIS
923 + + CLOSE_PARENTHESIS;
924 + }
925 +
926 + private static String getAttrTypeForFilterContentMatchWhenNonPremitiveDatatype(String attributeName) {
927 + return APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
928 + + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE
929 + + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
930 + + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD
931 + + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
932 + + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS;
933 + }
934 +
935 + private static String getIfFilterContentMatchMethodImpl(String attributeName,
936 + String filterMethod, int numleaf, YangType dataType) {
937 + String attrQualifiedType;
938 +
939 + if (isPrimitiveDataType(dataType.getDataType())) {
940 + attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName);
941 + } else if (dataType.getDataType() == LEAFREF) {
942 + YangType type = ((YangLeafRef) dataType.getDataTypeExtendedInfo()).getEffectiveDataType();
943 + if (isPrimitiveDataType(type.getDataType())) {
944 + attrQualifiedType = getAttrTypeForFilterContentMatchWhenPrimitiveDataType(attributeName);
945 + } else {
946 + attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPremitiveDatatype(attributeName);
947 + }
948 + } else {
949 + attrQualifiedType = getAttrTypeForFilterContentMatchWhenNonPremitiveDatatype(attributeName);
950 + }
951 +
952 + return attrQualifiedType;
899 } 953 }
900 954
901 /** 955 /**
...@@ -908,14 +962,16 @@ public final class MethodsGenerator { ...@@ -908,14 +962,16 @@ public final class MethodsGenerator {
908 */ 962 */
909 public static String getIsFilterContentMatch(String className, YangNode curNode, YangPluginConfig pluginConfig) { 963 public static String getIsFilterContentMatch(String className, YangNode curNode, YangPluginConfig pluginConfig) {
910 964
911 - int numleaf = 1; 965 + int numLeaf = 1;
912 - String filterMethod = NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE 966 + String filterMethod = "";
967 + TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
968 + .getTempJavaCodeFragmentFiles().getBeanTempFiles();
969 + if (curNode instanceof YangLeavesHolder) {
970 + filterMethod = NEW_LINE + NEW_LINE + FOUR_SPACE_INDENTATION + PUBLIC + SPACE + BOOLEAN_DATA_TYPE
913 + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + getCapitalCase(OBJECT) 971 + SPACE + FILTER_CONTENT_MATCH + OPEN_PARENTHESIS + getCapitalCase(OBJECT)
914 + SPACE + OBJ + 972 + SPACE + OBJ +
915 CLOSE_PARENTHESIS + SPACE 973 CLOSE_PARENTHESIS + SPACE
916 + OPEN_CURLY_BRACKET + NEW_LINE; 974 + OPEN_CURLY_BRACKET + NEW_LINE;
917 - TempJavaBeanFragmentFiles tempFragmentFiles = ((JavaCodeGeneratorInfo) curNode)
918 - .getTempJavaCodeFragmentFiles().getBeanTempFiles();
919 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + getCapitalCase(DEFAULT) 975 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + getCapitalCase(DEFAULT)
920 + getCapitalCase(className) + SPACE + APP_INSTANCE + SPACE + EQUAL + SPACE + OPEN_PARENTHESIS + 976 + getCapitalCase(className) + SPACE + APP_INSTANCE + SPACE + EQUAL + SPACE + OPEN_PARENTHESIS +
921 getCapitalCase(DEFAULT) + getCapitalCase(className) + CLOSE_PARENTHESIS + OBJ + 977 getCapitalCase(DEFAULT) + getCapitalCase(className) + CLOSE_PARENTHESIS + OBJ +
...@@ -924,78 +980,53 @@ public final class MethodsGenerator { ...@@ -924,78 +980,53 @@ public final class MethodsGenerator {
924 filterMethod = filterMethod + getAugmentableOpParamSyntax(); 980 filterMethod = filterMethod + getAugmentableOpParamSyntax();
925 } 981 }
926 982
927 - if (curNode instanceof YangLeavesHolder) {
928 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode; 983 YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
929 List<YangLeaf> leaves = leavesHolder.getListOfLeaf(); 984 List<YangLeaf> leaves = leavesHolder.getListOfLeaf();
930 List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList(); 985 List<YangLeafList> listOfLeafList = leavesHolder.getListOfLeafList();
986 + String attrQualifiedType;
931 if (leaves != null) { 987 if (leaves != null) {
932 for (YangLeaf leaf : leaves) { 988 for (YangLeaf leaf : leaves) {
933 JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeaf(tempFragmentFiles, leaf, 989 JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeaf(tempFragmentFiles, leaf,
934 pluginConfig); 990 pluginConfig);
935 String attributeName = javaAttributeInfo.getAttributeName(); 991 String attributeName = javaAttributeInfo.getAttributeName();
936 - 992 + attrQualifiedType = getIfFilterContentMatchMethodImpl(attributeName,
937 - String attrQuaifiedType = ""; 993 + filterMethod, numLeaf, leaf.getDataType());
938 - if (isPrimitiveDataType(leaf.getDataType().getDataType())) {
939 - attrQuaifiedType = APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
940 - + SPACE + NOT + EQUAL + SPACE + attributeName + OPEN_PARENTHESIS
941 - + CLOSE_PARENTHESIS;
942 - } else {
943 - attrQuaifiedType = APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
944 - + SPACE + EQUAL + EQUAL + SPACE + NULL + SPACE + OR_OPERATION + SPACE
945 - + NOT + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
946 - + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD
947 - + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
948 - + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS;
949 - }
950 -
951 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS 994 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS
952 + GET_FILTER_LEAF + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX 995 + GET_FILTER_LEAF + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX
953 - + OPEN_PARENTHESIS + String.valueOf(numleaf) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS 996 + + OPEN_PARENTHESIS + String.valueOf(numLeaf) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
954 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE 997 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE
955 - + OPEN_PARENTHESIS + attrQuaifiedType + CLOSE_PARENTHESIS + SPACE 998 + + OPEN_PARENTHESIS + attrQualifiedType + CLOSE_PARENTHESIS + SPACE
956 + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE 999 + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE
957 + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE 1000 + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE
958 + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 1001 + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
959 - numleaf++; 1002 +
1003 + numLeaf++;
960 } 1004 }
961 } 1005 }
962 1006
963 if (listOfLeafList != null) { 1007 if (listOfLeafList != null) {
964 - numleaf = 1; 1008 + numLeaf = 1;
965 for (YangLeafList leafList : listOfLeafList) { 1009 for (YangLeafList leafList : listOfLeafList) {
966 JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList, 1010 JavaAttributeInfo javaAttributeInfo = getJavaAttributeOfLeafList(tempFragmentFiles, leafList,
967 pluginConfig); 1011 pluginConfig);
968 String attributeName = javaAttributeInfo.getAttributeName(); 1012 String attributeName = javaAttributeInfo.getAttributeName();
969 - String attrQuaifiedType = ""; 1013 + attrQualifiedType = getIfFilterContentMatchMethodImpl(
970 - if (isPrimitiveDataType(leafList.getDataType().getDataType())) { 1014 + attributeName, filterMethod, numLeaf, leafList.getDataType());
971 - attrQuaifiedType = APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
972 - + SPACE + NOT + EQUAL + SPACE + attributeName + OPEN_PARENTHESIS
973 - + CLOSE_PARENTHESIS;
974 - } else {
975 - attrQuaifiedType = APP_INSTANCE + PERIOD + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
976 - + SPACE + EQUAL + EQUAL + SPACE + NULL + OR_OPERATION + OPEN_PARENTHESIS + NOT
977 - + OPEN_PARENTHESIS + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
978 - + PERIOD + EQUALS_STRING + OPEN_PARENTHESIS + APP_INSTANCE + PERIOD
979 - + attributeName + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
980 - + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS;
981 - }
982 -
983 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS 1015 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS
984 + GET_FILTER_LEAF_LIST + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX 1016 + GET_FILTER_LEAF_LIST + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + GET_METHOD_PREFIX
985 - + OPEN_PARENTHESIS + String.valueOf(numleaf) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS 1017 + + OPEN_PARENTHESIS + String.valueOf(numLeaf) + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS
986 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE 1018 + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE
987 - + OPEN_PARENTHESIS + attrQuaifiedType + CLOSE_PARENTHESIS + SPACE 1019 + + OPEN_PARENTHESIS + attrQualifiedType + CLOSE_PARENTHESIS + SPACE
988 + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE 1020 + OPEN_CURLY_BRACKET + NEW_LINE + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + FALSE
989 + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE 1021 + SEMI_COLAN + NEW_LINE + TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE
990 + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 1022 + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
991 - numleaf++; 1023 + numLeaf++;
992 } 1024 }
993 } 1025 }
994 1026
995 - if (leaves != null || listOfLeafList != null) {
996 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN + 1027 filterMethod = filterMethod + EIGHT_SPACE_INDENTATION + RETURN + SPACE + TRUE + SEMI_COLAN +
997 NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE; 1028 NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
998 - } 1029 +
999 } 1030 }
1000 return filterMethod; 1031 return filterMethod;
1001 } 1032 }
...@@ -1003,7 +1034,7 @@ public final class MethodsGenerator { ...@@ -1003,7 +1034,7 @@ public final class MethodsGenerator {
1003 /*Returns method string for op parms augmented syntax*/ 1034 /*Returns method string for op parms augmented syntax*/
1004 private static String getAugmentableOpParamSyntax() { 1035 private static String getAugmentableOpParamSyntax() {
1005 return EIGHT_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE + 1036 return EIGHT_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + YANG_AUGMENTED_INFO + SPACE +
1006 - getSmallCase(YANG_AUGMENTED_INFO) + SPACE + COLAN + SPACE + APP_INSTANCE + 1037 + getSmallCase(YANG_AUGMENTED_INFO) + SPACE + COLAN + SPACE + THIS +
1007 PERIOD + GET_METHOD_PREFIX + YANG_AUGMENTED_INFO + MAP + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD 1038 PERIOD + GET_METHOD_PREFIX + YANG_AUGMENTED_INFO + MAP + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD
1008 + VALUE + "s" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + 1039 + VALUE + "s" + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET +
1009 NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + NOT + OPEN_PARENTHESIS + 1040 NEW_LINE + TWELVE_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + NOT + OPEN_PARENTHESIS +
...@@ -1361,6 +1392,35 @@ public final class MethodsGenerator { ...@@ -1361,6 +1392,35 @@ public final class MethodsGenerator {
1361 } 1392 }
1362 1393
1363 /** 1394 /**
1395 + * Returns string and java doc for constructor of type class.
1396 + *
1397 + * @param attr1 first attribute info
1398 + * @param attr2 second attribute info
1399 + * @param generatedJavaClassName class name
1400 + * @param pluginConfig plugin config
1401 + * @param type conflict validate type
1402 + * @param addFirst whether int came first or uint came first
1403 + * @return string and java doc for constructor of type class
1404 + */
1405 + public static String getTypeConstructorStringAndJavaDoc(JavaAttributeInfo attr1, JavaAttributeInfo
1406 + attr2, String generatedJavaClassName, YangPluginConfig pluginConfig, ValidatorTypeForUnionTypes type,
1407 + boolean addFirst) {
1408 +
1409 + String attrType = getReturnType(attr1);
1410 + String attrName1 = "";
1411 + String attrName2 = "";
1412 + if (attr1 != null) {
1413 + attrName1 = attr1.getAttributeName();
1414 + }
1415 + if (attr2 != null) {
1416 + attrName2 = attr2.getAttributeName();
1417 + }
1418 +
1419 + return getJavaDoc(TYPE_CONSTRUCTOR, generatedJavaClassName + " for type " + attrName1, false, pluginConfig)
1420 + + getTypeConstructorString(attrType, attrName1, attrName2, generatedJavaClassName, type, addFirst);
1421 + }
1422 +
1423 + /**
1364 * Returns type constructor string. 1424 * Returns type constructor string.
1365 * 1425 *
1366 * @param type data type 1426 * @param type data type
...@@ -1377,6 +1437,42 @@ public final class MethodsGenerator { ...@@ -1377,6 +1437,42 @@ public final class MethodsGenerator {
1377 } 1437 }
1378 1438
1379 /** 1439 /**
1440 + * Returns type constructor string.
1441 + *
1442 + * @param type data type
1443 + * @param attr1 attribute attr1
1444 + * @param className class attr1
1445 + * @return type constructor string
1446 + */
1447 + private static String getTypeConstructorString(String type, String attr1, String attr2, String className,
1448 + ValidatorTypeForUnionTypes validatorType, boolean addInt) {
1449 +
1450 + String constructor;
1451 + constructor = FOUR_SPACE_INDENTATION + PUBLIC + SPACE + className + OPEN_PARENTHESIS + type + SPACE + VALUE
1452 + + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
1453 +
1454 + String name1;
1455 + String name2;
1456 + if (addInt) {
1457 + name1 = attr1;
1458 + name2 = attr2;
1459 + } else {
1460 + name1 = attr2;
1461 + name2 = attr1;
1462 + }
1463 + constructor = constructor + ifConditionForIntInTypeDefConstrcutor(validatorType, addInt) +
1464 + TWELVE_SPACE_INDENTATION + THIS + PERIOD
1465 + + name1 + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION
1466 + + CLOSE_CURLY_BRACKET + SPACE + ELSE + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + TWELVE_SPACE_INDENTATION
1467 + + THIS + PERIOD
1468 + + name2 + SPACE + EQUAL + SPACE + VALUE + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION
1469 + + CLOSE_CURLY_BRACKET + NEW_LINE + FOUR_SPACE_INDENTATION
1470 + + CLOSE_CURLY_BRACKET;
1471 +
1472 + return constructor;
1473 + }
1474 +
1475 + /**
1380 * Returns implementation of add augmentation. 1476 * Returns implementation of add augmentation.
1381 * 1477 *
1382 * @return implementation of add augmentation 1478 * @return implementation of add augmentation
...@@ -1469,7 +1565,7 @@ public final class MethodsGenerator { ...@@ -1469,7 +1565,7 @@ public final class MethodsGenerator {
1469 + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET 1565 + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET
1470 + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET; 1566 + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
1471 1567
1472 - return getJavaDoc(OF_METHOD, getCapitalCase(className) + " for type" + attrName, false, pluginConfig) 1568 + return getJavaDoc(OF_METHOD, getCapitalCase(className) + " for type " + attrName, false, pluginConfig)
1473 + method; 1569 + method;
1474 } 1570 }
1475 1571
...@@ -1577,13 +1673,15 @@ public final class MethodsGenerator { ...@@ -1577,13 +1673,15 @@ public final class MethodsGenerator {
1577 StringBuilder methods = new StringBuilder(); 1673 StringBuilder methods = new StringBuilder();
1578 String parentName; 1674 String parentName;
1579 String returnType; 1675 String returnType;
1676 + YangNode methodNode;
1580 YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig(); 1677 YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig();
1581 for (YangAtomicPath nodeId : targets) { 1678 for (YangAtomicPath nodeId : targets) {
1582 augmentedNode = nodeId.getResolvedNode().getParent(); 1679 augmentedNode = nodeId.getResolvedNode().getParent();
1583 - if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { 1680 + methodNode = nodeId.getResolvedNode();
1584 - curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); 1681 + if (((JavaFileInfoContainer) methodNode).getJavaFileInfo().getJavaName() != null) {
1682 + curNodeName = ((JavaFileInfoContainer) methodNode).getJavaFileInfo().getJavaName();
1585 } else { 1683 } else {
1586 - curNodeName = getCapitalCase(getCamelCase(augmentedNode.getName(), pluginConfig 1684 + curNodeName = getCapitalCase(getCamelCase(methodNode.getName(), pluginConfig
1587 .getConflictResolver())); 1685 .getConflictResolver()));
1588 } 1686 }
1589 returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent); 1687 returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent);
...@@ -1596,7 +1694,7 @@ public final class MethodsGenerator { ...@@ -1596,7 +1694,7 @@ public final class MethodsGenerator {
1596 methods.append(method); 1694 methods.append(method);
1597 1695
1598 method = getJavaDoc(MANAGER_SETTER_METHOD, AUGMENTED + 1696 method = getJavaDoc(MANAGER_SETTER_METHOD, AUGMENTED +
1599 - getCapitalCase(parentName) + curNodeName, false, pluginConfig) + 1697 + getCapitalCase(parentName) + getCapitalCase(curNodeName), false, pluginConfig) +
1600 getSetterForInterface(getSmallCase(AUGMENTED) + parentName + 1698 getSetterForInterface(getSmallCase(AUGMENTED) + parentName +
1601 getCapitalCase(curNodeName), returnType, parentName, 1699 getCapitalCase(curNodeName), returnType, parentName,
1602 false, 1700 false,
...@@ -1620,13 +1718,15 @@ public final class MethodsGenerator { ...@@ -1620,13 +1718,15 @@ public final class MethodsGenerator {
1620 String method; 1718 String method;
1621 StringBuilder methods = new StringBuilder(); 1719 StringBuilder methods = new StringBuilder();
1622 String parentName; 1720 String parentName;
1721 + YangNode methodNode;
1623 YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig(); 1722 YangPluginConfig pluginConfig = ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig();
1624 for (YangAtomicPath nodeId : targets) { 1723 for (YangAtomicPath nodeId : targets) {
1625 augmentedNode = nodeId.getResolvedNode().getParent(); 1724 augmentedNode = nodeId.getResolvedNode().getParent();
1626 - if (((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName() != null) { 1725 + methodNode = nodeId.getResolvedNode();
1627 - curNodeName = ((JavaFileInfoContainer) augmentedNode).getJavaFileInfo().getJavaName(); 1726 + if (((JavaFileInfoContainer) methodNode).getJavaFileInfo().getJavaName() != null) {
1727 + curNodeName = ((JavaFileInfoContainer) methodNode).getJavaFileInfo().getJavaName();
1628 } else { 1728 } else {
1629 - curNodeName = getCapitalCase(getCamelCase(augmentedNode.getName(), pluginConfig 1729 + curNodeName = getCapitalCase(getCamelCase(methodNode.getName(), pluginConfig
1630 .getConflictResolver())); 1730 .getConflictResolver()));
1631 } 1731 }
1632 returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent); 1732 returnType = getAugmentedClassNameForDataMethods(augmentedNode, parent);
...@@ -1646,4 +1746,66 @@ public final class MethodsGenerator { ...@@ -1646,4 +1746,66 @@ public final class MethodsGenerator {
1646 return methods.toString(); 1746 return methods.toString();
1647 } 1747 }
1648 1748
1749 + /**
1750 + * Returns validator method for range in union class.
1751 + *
1752 + * @param type type
1753 + * @return validator method for range in union class
1754 + */
1755 + public static String getRangeValidatorMethodForUnion(String type) {
1756 + String newType;
1757 + if (type.contentEquals(BIG_INTEGER)) {
1758 + newType = LONG;
1759 + } else {
1760 + newType = INT;
1761 + }
1762 + String method = generateForValidatorMethod() + FOUR_SPACE_INDENTATION + PRIVATE + SPACE + BOOLEAN_DATA_TYPE +
1763 + SPACE +
1764 + VALIDATE_RANGE +
1765 + OPEN_PARENTHESIS
1766 + + type + SPACE + MIN_RANGE + COMMA + SPACE + type + SPACE + MAX_RANGE + COMMA + SPACE +
1767 + newType + SPACE + VALUE + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
1768 + if (type.contentEquals(BIG_INTEGER)) {
1769 + method = method + EIGHT_SPACE_INDENTATION + BIG_INTEGER + SPACE + getSmallCase(BIG_INTEGER)
1770 + + SPACE + EQUAL + SPACE + NEW + SPACE + BIG_INTEGER + OPEN_PARENTHESIS + QUOTES + SPACE +
1771 + QUOTES + SPACE + ADD + SPACE + VALUE + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE +
1772 + EIGHT_SPACE_INDENTATION + RETURN + SPACE + getSmallCase(BIG_INTEGER) + PERIOD + "compareTo"
1773 + + OPEN_PARENTHESIS + MIN_RANGE + CLOSE_PARENTHESIS + SPACE + EQUAL + EQUAL + " 1" + SPACE + AND +
1774 + AND + SPACE + getSmallCase(BIG_INTEGER) + PERIOD + "compareTo" + OPEN_PARENTHESIS + MAX_RANGE +
1775 + CLOSE_PARENTHESIS + SPACE + EQUAL + EQUAL + " 1" + SEMI_COLAN + NEW_LINE;
1776 + } else {
1777 + method = method + EIGHT_SPACE_INDENTATION
1778 + + RETURN + SPACE + VALUE + SPACE + DIAMOND_CLOSE_BRACKET + EQUAL + SPACE + MIN_RANGE + SPACE + AND +
1779 + AND + SPACE + VALUE + DIAMOND_OPEN_BRACKET + EQUAL + SPACE + MAX_RANGE + SEMI_COLAN + NEW_LINE;
1780 + }
1781 + return method + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
1782 + }
1783 +
1784 + /**
1785 + * Returns if condition string for typedef constructor.
1786 + *
1787 + * @param type type of conflict
1788 + * @param addFirst true int/long need to be added first
1789 + * @return if condition string for typedef constructor
1790 + */
1791 + private static String ifConditionForIntInTypeDefConstrcutor(ValidatorTypeForUnionTypes type, boolean addFirst) {
1792 + String condition = EIGHT_SPACE_INDENTATION + IF + SPACE + OPEN_PARENTHESIS + VALIDATE_RANGE + OPEN_PARENTHESIS;
1793 +
1794 + if (type == INT_TYPE_CONFLICT) {
1795 + if (addFirst) {
1796 + condition = condition + INT_MIN_RANGE + COMMA + SPACE + INT_MAX_RANGE + COMMA + SPACE + VALUE;
1797 + } else {
1798 + condition = condition + UINT_MIN_RANGE + COMMA + SPACE + UINT_MAX_RANGE + COMMA + SPACE + VALUE;
1799 + }
1800 + } else {
1801 + if (addFirst) {
1802 + condition = condition + LONG_MIN_RANGE + COMMA + SPACE + LONG_MAX_RANGE + COMMA + SPACE + VALUE;
1803 + } else {
1804 + condition = condition + ULONG_MIN_RANGE + COMMA + SPACE + ULONG_MAX_RANGE + COMMA + SPACE + VALUE;
1805 + }
1806 + }
1807 + return condition + CLOSE_PARENTHESIS + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
1808 + }
1809 +
1810 +
1649 } 1811 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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.translator.tojava.utils;
18 +
19 +/**
20 + * Validator types for union when there is conflict between two types.
21 + */
22 +public enum ValidatorTypeForUnionTypes {
23 +
24 + /**
25 + * When conflict is there for int32 and uint16.
26 + */
27 + INT_TYPE_CONFLICT,
28 +
29 + /**
30 + * When conflict is there for int64 and uint32.
31 + */
32 + LONG_TYPE_CONFLICT
33 +}
...@@ -127,6 +127,16 @@ public final class UtilConstants { ...@@ -127,6 +127,16 @@ public final class UtilConstants {
127 public static final String JAVA_DOC_GETTERS = " * Returns the attribute "; 127 public static final String JAVA_DOC_GETTERS = " * Returns the attribute ";
128 128
129 /** 129 /**
130 + * JavaDocs's description for getter method.
131 + */
132 + public static final String JAVA_DOC_FOR_VALIDATOR = " * Validates if value is in given range.";
133 +
134 + /**
135 + * JavaDocs's description for getter method.
136 + */
137 + public static final String JAVA_DOC_FOR_VALIDATOR_RETURN = " * @return true if value is in range";
138 +
139 + /**
130 * JavaDocs's description for constructor. 140 * JavaDocs's description for constructor.
131 */ 141 */
132 public static final String JAVA_DOC_CONSTRUCTOR = " * Creates an instance of "; 142 public static final String JAVA_DOC_CONSTRUCTOR = " * Creates an instance of ";
...@@ -292,6 +302,108 @@ public final class UtilConstants { ...@@ -292,6 +302,108 @@ public final class UtilConstants {
292 public static final String SPACE = " "; 302 public static final String SPACE = " ";
293 303
294 /** 304 /**
305 + * Static attribute for validateRange.
306 + */
307 + public static final String VALIDATE_RANGE = "validateRange";
308 +
309 + /**
310 + * Static attribute for minRange.
311 + */
312 + public static final String MIN_RANGE = "minRange";
313 +
314 + /**
315 + * Static attribute for maxRange.
316 + */
317 + public static final String MAX_RANGE = "maxRange";
318 +
319 + /**
320 + * Static attribute for minRange.
321 + */
322 + public static final String INT_MIN_RANGE_ATTR = "static final int INT32_MIN_RANGE = -2147483648;\n";
323 +
324 + /**
325 + * Static attribute for minRange.
326 + */
327 + public static final String INT_MIN_RANGE = "INT32_MIN_RANGE";
328 +
329 + /**
330 + * Static attribute for minRange.
331 + */
332 + public static final String INT_MAX_RANGE = "INT32_MAX_RANGE";
333 +
334 + /**
335 + * Static attribute for maxRange.
336 + */
337 + public static final String INT_MAX_RANGE_ATTR = "static final int INT32_MAX_RANGE = 2147483647;";
338 +
339 +
340 + /**
341 + * Static attribute for minRange.
342 + */
343 + public static final String UINT_MIN_RANGE_ATTR = "static final int UINT16_MIN_RANGE = 0;\n";
344 +
345 + /**
346 + * Static attribute for maxRange.
347 + */
348 + public static final String UINT_MAX_RANGE_ATTR = "static final int UINT16_MAX_RANGE = 2147483647;";
349 +
350 +
351 + /**
352 + * Static attribute for minRange.
353 + */
354 + public static final String UINT_MIN_RANGE = "UINT16_MIN_RANGE";
355 +
356 + /**
357 + * Static attribute for maxRange.
358 + */
359 + public static final String UINT_MAX_RANGE = "UINT16_MAX_RANGE";
360 +
361 + /**
362 + * Static attribute for minRange.
363 + */
364 + public static final String LONG_MIN_RANGE_ATTR = "static final BigInteger INT64_MIN_RANGE =" +
365 + " new BigInteger(\"-9223372036854775808\");\n";
366 +
367 + /**
368 + * Static attribute for maxRange.
369 + */
370 + public static final String LONG_MAX_RANGE_ATTR = "static final BigInteger INT64_MAX_RANGE =" +
371 + " new BigInteger(\"9223372036854775807\");";
372 +
373 + /**
374 + * Static attribute for minRange.
375 + */
376 + public static final String LONG_MIN_RANGE = "INT64_MIN_RANGE";
377 +
378 + /**
379 + * Static attribute for maxRange.
380 + */
381 + public static final String LONG_MAX_RANGE = "INT64_MAX_RANGE";
382 +
383 + /**
384 + * Static attribute for minRange.
385 + */
386 + public static final String ULONG_MIN_RANGE_ATTR = "static final BigInteger UINT32_MIN_RANGE =" +
387 + " new BigInteger(\"0\");\n";
388 +
389 + /**
390 + * Static attribute for maxRange.
391 + */
392 + public static final String ULONG_MAX_RANGE_ATTR = "static final BigInteger UINT32_MAX_RANGE =" +
393 + " new BigInteger(\"9223372036854775807\");";
394 +
395 +
396 + /**
397 + * Static attribute for minRange.
398 + */
399 + public static final String ULONG_MIN_RANGE = "UINT32_MIN_RANGE";
400 +
401 + /**
402 + * Static attribute for maxRange.
403 + */
404 + public static final String ULONG_MAX_RANGE = "UINT32_MAX_RANGE";
405 +
406 + /**
295 * Static attribute for subject. 407 * Static attribute for subject.
296 */ 408 */
297 public static final String SUBJECT = "Subject"; 409 public static final String SUBJECT = "Subject";
...@@ -347,16 +459,6 @@ public final class UtilConstants { ...@@ -347,16 +459,6 @@ public final class UtilConstants {
347 public static final String IDENTITYREF = "identityref"; 459 public static final String IDENTITYREF = "identityref";
348 460
349 /** 461 /**
350 - * Static attribute for binary string.
351 - */
352 - public static final String BINARY_STRING = "binary";
353 -
354 - /**
355 - * Static attribute for bits string.
356 - */
357 - public static final String BITS_STRING = "bits";
358 -
359 - /**
360 * Static attribute for output variable of rpc. 462 * Static attribute for output variable of rpc.
361 */ 463 */
362 public static final String RPC_INPUT_VAR_NAME = "inputVar"; 464 public static final String RPC_INPUT_VAR_NAME = "inputVar";
...@@ -612,6 +714,11 @@ public final class UtilConstants { ...@@ -612,6 +714,11 @@ public final class UtilConstants {
612 public static final String TMP_VAL = "tmpVal"; 714 public static final String TMP_VAL = "tmpVal";
613 715
614 /** 716 /**
717 + * Static attribute for close curly bracket syntax.
718 + */
719 + public static final String ELSE = "else";
720 +
721 + /**
615 * From string parameter name. 722 * From string parameter name.
616 */ 723 */
617 public static final String FROM_STRING_PARAM_NAME = "valInString"; 724 public static final String FROM_STRING_PARAM_NAME = "valInString";
......
...@@ -17,6 +17,10 @@ ...@@ -17,6 +17,10 @@
17 package org.onosproject.yangutils.utils.io.impl; 17 package org.onosproject.yangutils.utils.io.impl;
18 18
19 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED; 19 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
20 +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR;
21 +import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_FOR_VALIDATOR_RETURN;
22 +import static org.onosproject.yangutils.utils.UtilConstants.MAX_RANGE;
23 +import static org.onosproject.yangutils.utils.UtilConstants.MIN_RANGE;
20 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO; 24 import static org.onosproject.yangutils.utils.UtilConstants.YANG_AUGMENTED_INFO;
21 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER; 25 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
22 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC; 26 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC;
...@@ -519,6 +523,11 @@ public final class JavaDocGen { ...@@ -519,6 +523,11 @@ public final class JavaDocGen {
519 VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE; 523 VALUE + SPACE + OF + SPACE + AUGMENTED + CLASS + NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_END_LINE;
520 } 524 }
521 525
526 + /**
527 + * Returns javadoc for get augmentation method.
528 + *
529 + * @return javadoc for get augmentation method
530 + */
522 public static String generateForGetAugmentation() { 531 public static String generateForGetAugmentation() {
523 return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION 532 return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION
524 + JAVA_DOC_GETTERS + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD + NEW_LINE + 533 + JAVA_DOC_GETTERS + getSmallCase(YANG_AUGMENTED_INFO) + PERIOD + NEW_LINE +
...@@ -529,6 +538,23 @@ public final class JavaDocGen { ...@@ -529,6 +538,23 @@ public final class JavaDocGen {
529 } 538 }
530 539
531 /** 540 /**
541 + * Returns javadoc for validator method.
542 + *
543 + * @return javadoc for validator method
544 + */
545 + public static String generateForValidatorMethod() {
546 + return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION +
547 + JAVA_DOC_FOR_VALIDATOR + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK +
548 + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + MIN_RANGE + SPACE + MIN_RANGE + SPACE + OF + SPACE +
549 + VALUE + NEW_LINE +
550 + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + MAX_RANGE + SPACE + MAX_RANGE + SPACE + OF + SPACE + VALUE +
551 + NEW_LINE +
552 + FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + VALUE + SPACE + VALUE + NEW_LINE +
553 + FOUR_SPACE_INDENTATION + JAVA_DOC_FOR_VALIDATOR_RETURN + NEW_LINE + FOUR_SPACE_INDENTATION +
554 + JAVA_DOC_END_LINE;
555 + }
556 +
557 + /**
532 * JavaDocs types. 558 * JavaDocs types.
533 */ 559 */
534 public enum JavaDocType { 560 public enum JavaDocType {
......
...@@ -39,7 +39,7 @@ public class ManagerCodeGeneratorTest { ...@@ -39,7 +39,7 @@ public class ManagerCodeGeneratorTest {
39 /** 39 /**
40 * Checks manager translation should not result in any exception. 40 * Checks manager translation should not result in any exception.
41 * 41 *
42 - * @throws MojoExecutionException 42 + * @throws MojoExecutionException when fails to do mojo operations
43 */ 43 */
44 @Test 44 @Test
45 public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException { 45 public void processManagerTranslator() throws IOException, ParserException, MojoExecutionException {
...@@ -73,7 +73,7 @@ public class ManagerCodeGeneratorTest { ...@@ -73,7 +73,7 @@ public class ManagerCodeGeneratorTest {
73 /** 73 /**
74 * Checks manager translation in different package should not result in any exception. 74 * Checks manager translation in different package should not result in any exception.
75 * 75 *
76 - * @throws MojoExecutionException 76 + * @throws MojoExecutionException when fails to do mojo operations
77 */ 77 */
78 @Test 78 @Test
79 public void processManagerInDifferentPackageTranslator() throws IOException, ParserException, 79 public void processManagerInDifferentPackageTranslator() throws IOException, ParserException,
...@@ -102,7 +102,7 @@ public class ManagerCodeGeneratorTest { ...@@ -102,7 +102,7 @@ public class ManagerCodeGeneratorTest {
102 /** 102 /**
103 * Checks manager translation in different package should not result in any exception. 103 * Checks manager translation in different package should not result in any exception.
104 * 104 *
105 - * @throws MojoExecutionException 105 + * @throws MojoExecutionException when fails to do mojo operations
106 */ 106 */
107 @Test 107 @Test
108 public void processManagerforMultiChildTranslator() throws IOException, ParserException, 108 public void processManagerforMultiChildTranslator() throws IOException, ParserException,
...@@ -140,6 +140,42 @@ public class ManagerCodeGeneratorTest { ...@@ -140,6 +140,42 @@ public class ManagerCodeGeneratorTest {
140 assertThat(true, is(manager4.exists())); 140 assertThat(true, is(manager4.exists()));
141 141
142 deleteDirectory("target/manager/"); 142 deleteDirectory("target/manager/");
143 + deleteDirectory("target/manager/");
144 + }
145 +
146 + /**
147 + * Checks manager translation in different package should not result in any exception.
148 + *
149 + * @throws MojoExecutionException when fails to do mojo operations
150 + */
151 + @Test
152 + public void processManagerforMultiChildWithDifferentPackageTranslator() throws IOException, ParserException,
153 + MojoExecutionException {
154 +
155 + String searchDir = "src/test/resources/manager/MultiChild";
156 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
157 + utilManager.parseYangFileInfoSet();
158 + utilManager.createYangNodeSet();
159 + utilManager.resolveDependenciesUsingLinker();
160 +
161 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
162 + yangPluginConfig.setCodeGenDir("target/manager/");
163 + yangPluginConfig.setManagerCodeGenDir("target/manager1/");
164 +
165 + utilManager.translateToJava(yangPluginConfig);
166 +
167 + String file1 = "target/manager1/org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8Manager.java";
168 +
169 + File manager1 = new File(file1);
170 + assertThat(true, is(manager1.exists()));
171 +
172 +
173 + String file2 = "target/manager/org/onosproject/yang/gen/v1/test8/test/rev20160704/Test8Service.java";
174 +
175 + File service2 = new File(file2);
176 + assertThat(true, is(service2.exists()));
177 +
178 + deleteDirectory("target/manager/");
143 deleteDirectory("target/manager1/"); 179 deleteDirectory("target/manager1/");
144 } 180 }
145 } 181 }
......
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
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.plugin.manager;
18 +
19 +import java.io.IOException;
20 +
21 +import org.apache.maven.plugin.MojoExecutionException;
22 +import org.junit.Test;
23 +import org.onosproject.yangutils.parser.exceptions.ParserException;
24 +import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
25 +import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
26 +
27 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
28 +
29 +/**
30 + * Unit test case for typedef translator.
31 + */
32 +public class TypeDefTranslatorTest {
33 +
34 + private final YangUtilManager utilManager = new YangUtilManager();
35 +
36 + /**
37 + * Checks typedef translation should not result in any exception.
38 + *
39 + * @throws MojoExecutionException
40 + */
41 + @Test
42 + public void processTypeDefTranslator() throws IOException, ParserException, MojoExecutionException {
43 +
44 + String searchDir = "src/test/resources/typedefTranslator";
45 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
46 + utilManager.parseYangFileInfoSet();
47 + utilManager.createYangNodeSet();
48 + utilManager.resolveDependenciesUsingLinker();
49 +
50 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
51 + yangPluginConfig.setCodeGenDir("target/typedefTranslator/");
52 + yangPluginConfig.setManagerCodeGenDir("target/typedefTranslator/");
53 + utilManager.translateToJava(yangPluginConfig);
54 +
55 + deleteDirectory("target/typedefTranslator/");
56 + }
57 +
58 +}
...@@ -18,10 +18,12 @@ package org.onosproject.yangutils.plugin.manager; ...@@ -18,10 +18,12 @@ package org.onosproject.yangutils.plugin.manager;
18 18
19 import java.io.IOException; 19 import java.io.IOException;
20 20
21 +import org.apache.maven.plugin.MojoExecutionException;
21 import org.junit.Test; 22 import org.junit.Test;
22 import org.onosproject.yangutils.datamodel.YangNode; 23 import org.onosproject.yangutils.datamodel.YangNode;
23 import org.onosproject.yangutils.parser.exceptions.ParserException; 24 import org.onosproject.yangutils.parser.exceptions.ParserException;
24 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager; 25 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
26 +import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
25 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig; 27 import org.onosproject.yangutils.utils.io.impl.YangPluginConfig;
26 28
27 import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode; 29 import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
...@@ -52,5 +54,168 @@ public final class UnionTranslatorTest { ...@@ -52,5 +54,168 @@ public final class UnionTranslatorTest {
52 deleteDirectory("target/UnionTestGenFile/"); 54 deleteDirectory("target/UnionTestGenFile/");
53 } 55 }
54 56
57 + /**
58 + * Unit test case to test conflicting types.
59 + *
60 + * @throws IOException when fails to do IO operations
61 + * @throws MojoExecutionException when fails to do mojo operations
62 + */
63 + @Test
64 + public void processUnionIntUintConflictingTypes() throws IOException, MojoExecutionException {
65 + String searchDir = "src/test/resources/unionTranslator/intuint";
66 + YangUtilManager utilManager = new YangUtilManager();
67 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
68 + utilManager.parseYangFileInfoSet();
69 + utilManager.createYangNodeSet();
70 + utilManager.resolveDependenciesUsingLinker();
71 +
72 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
73 + yangPluginConfig.setCodeGenDir("target/unionTranslator/");
74 + yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
75 +
76 + utilManager.translateToJava(yangPluginConfig);
77 + deleteDirectory("target/unionTranslator/");
78 + }
79 +
80 + /**
81 + * Unit test case to test conflicting types.
82 + *
83 + * @throws IOException when fails to do IO operations
84 + * @throws MojoExecutionException when fails to do mojo operations
85 + */
86 + @Test
87 + public void processUnionUintIntConflictingTypes() throws IOException, MojoExecutionException {
88 + String searchDir = "src/test/resources/unionTranslator/uintint";
89 + YangUtilManager utilManager = new YangUtilManager();
90 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
91 + utilManager.parseYangFileInfoSet();
92 + utilManager.createYangNodeSet();
93 + utilManager.resolveDependenciesUsingLinker();
94 +
95 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
96 + yangPluginConfig.setCodeGenDir("target/unionTranslator/");
97 + yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
98 +
99 + utilManager.translateToJava(yangPluginConfig);
100 + deleteDirectory("target/unionTranslator/");
101 + }
102 +
103 + /**
104 + * Unit test case to test conflicting types.
105 + *
106 + * @throws IOException when fails to do IO operations
107 + * @throws MojoExecutionException when fails to do mojo operations
108 + */
109 + @Test
110 + public void processUnionLongUlongConflictingTypes() throws IOException, MojoExecutionException {
111 + String searchDir = "src/test/resources/unionTranslator/longulong";
112 + YangUtilManager utilManager = new YangUtilManager();
113 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
114 + utilManager.parseYangFileInfoSet();
115 + utilManager.createYangNodeSet();
116 + utilManager.resolveDependenciesUsingLinker();
117 +
118 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
119 + yangPluginConfig.setCodeGenDir("target/unionTranslator/");
120 + yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
121 +
122 + utilManager.translateToJava(yangPluginConfig);
123 + deleteDirectory("target/unionTranslator/");
124 + }
125 +
126 + /**
127 + * Unit test case to test conflicting types.
128 + *
129 + * @throws IOException when fails to do IO operations
130 + * @throws MojoExecutionException when fails to do mojo operations
131 + */
132 + @Test
133 + public void processUnionUlongLongConflictingTypes() throws IOException, MojoExecutionException {
134 + String searchDir = "src/test/resources/unionTranslator/ulonglong";
135 + YangUtilManager utilManager = new YangUtilManager();
136 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
137 + utilManager.parseYangFileInfoSet();
138 + utilManager.createYangNodeSet();
139 + utilManager.resolveDependenciesUsingLinker();
140 +
141 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
142 + yangPluginConfig.setCodeGenDir("target/unionTranslator/");
143 + yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
144 +
145 + utilManager.translateToJava(yangPluginConfig);
146 + deleteDirectory("target/unionTranslator/");
147 + }
148 +
149 + /**
150 + * Unit test case to test conflicting types.
151 + *
152 + * @throws IOException when fails to do IO operations
153 + * @throws MojoExecutionException when fails to do mojo operations
154 + */
155 + @Test
156 + public void processUnionIntUintUlongLongConflictingTypes() throws IOException, MojoExecutionException {
157 + String searchDir = "src/test/resources/unionTranslator/intuintulonglong";
158 + YangUtilManager utilManager = new YangUtilManager();
159 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
160 + utilManager.parseYangFileInfoSet();
161 + utilManager.createYangNodeSet();
162 + utilManager.resolveDependenciesUsingLinker();
163 +
164 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
165 + yangPluginConfig.setCodeGenDir("target/unionTranslator/");
166 + yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
167 +
168 + utilManager.translateToJava(yangPluginConfig);
169 + deleteDirectory("target/unionTranslator/");
170 + }
171 +
172 + /**
173 + * Unit test case to test conflicting types.
174 + *
175 + * @throws IOException when fails to do IO operations
176 + * @throws MojoExecutionException when fails to do mojo operations
177 + */
178 + @Test
179 + public void processUnionIntUintUlongLongStringConflictingTypes() throws IOException,
180 + MojoExecutionException {
181 + String searchDir = "src/test/resources/unionTranslator/intuintulonglongstring";
182 + YangUtilManager utilManager = new YangUtilManager();
183 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
184 + utilManager.parseYangFileInfoSet();
185 + utilManager.createYangNodeSet();
186 + utilManager.resolveDependenciesUsingLinker();
187 +
188 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
189 + yangPluginConfig.setCodeGenDir("target/unionTranslator/");
190 + yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
191 +
192 + utilManager.translateToJava(yangPluginConfig);
193 + deleteDirectory("target/unionTranslator/");
194 + }
195 +
196 + /**
197 + * Unit test case to test conflicting types.
198 + *
199 + * @throws IOException when fails to do IO operations
200 + * @throws MojoExecutionException when fails to do mojo operations
201 + */
202 + @Test
203 + public void processUnionIntUintStringConflictingTypes() throws IOException,
204 + MojoExecutionException {
205 + String searchDir = "src/test/resources/unionTranslator/intuintstring";
206 + YangUtilManager utilManager = new YangUtilManager();
207 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
208 + utilManager.parseYangFileInfoSet();
209 + utilManager.createYangNodeSet();
210 + utilManager.resolveDependenciesUsingLinker();
211 +
212 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
213 + yangPluginConfig.setCodeGenDir("target/unionTranslator/");
214 + yangPluginConfig.setManagerCodeGenDir("target/unionTranslator/");
215 +
216 + utilManager.translateToJava(yangPluginConfig);
217 + deleteDirectory("target/unionTranslator/");
218 + }
219 +
55 // TODO enhance the test cases, after having a framework of translator test. 220 // TODO enhance the test cases, after having a framework of translator test.
56 } 221 }
......
1 +module ietf-yang-types {
2 +
3 + yang-version 1;
4 +
5 + namespace
6 + "urn:ietf:params:xml:ns:yang:ietf-yang-types";
7 +
8 + prefix yang;
9 +
10 + organization
11 + "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
12 +
13 + contact
14 + "WG Web: <http://tools.ietf.org/wg/netmod/>
15 + WG List: <mailto:netmod@ietf.org>
16 +
17 + WG Chair: David Kessens
18 + <mailto:david.kessens@nsn.com>
19 +
20 + WG Chair: Juergen Schoenwaelder
21 + <mailto:j.schoenwaelder@jacobs-university.de>
22 +
23 + Editor: Juergen Schoenwaelder
24 + <mailto:j.schoenwaelder@jacobs-university.de>";
25 +
26 + description
27 + "This module contains a collection of generally useful derived
28 + YANG data types.
29 +
30 + Copyright (c) 2013 IETF Trust and the persons identified as
31 + authors of the code. All rights reserved.
32 +
33 + Redistribution and use in source and binary forms, with or
34 + without modification, is permitted pursuant to, and subject
35 + to the license terms contained in, the Simplified BSD License
36 + set forth in Section 4.c of the IETF Trust's Legal Provisions
37 + Relating to IETF Documents
38 + (http://trustee.ietf.org/license-info).
39 +
40 + This version of this YANG module is part of RFC 6991; see
41 + the RFC itself for full legal notices.";
42 +
43 + revision "2013-07-15" {
44 + description
45 + "This revision adds the following new data types:
46 + - yang-identifier
47 + - hex-string
48 + - uuid
49 + - dotted-quad";
50 + reference
51 + "RFC 6991: Common YANG Data Types";
52 +
53 + }
54 +
55 + revision "2010-09-24" {
56 + description "Initial revision.";
57 + reference
58 + "RFC 6021: Common YANG Data Types";
59 +
60 + }
61 +
62 +
63 + typedef counter32 {
64 + type uint32;
65 + description
66 + "The counter32 type represents a non-negative integer
67 + that monotonically increases until it reaches a
68 + maximum value of 2^32-1 (4294967295 decimal), when it
69 + wraps around and starts increasing again from zero.
70 +
71 + Counters have no defined 'initial' value, and thus, a
72 + single value of a counter has (in general) no information
73 + content. Discontinuities in the monotonically increasing
74 + value normally occur at re-initialization of the
75 + management system, and at other times as specified in the
76 + description of a schema node using this type. If such
77 + other times can occur, for example, the creation of
78 + a schema node of type counter32 at times other than
79 + re-initialization, then a corresponding schema node
80 + should be defined, with an appropriate type, to indicate
81 + the last discontinuity.
82 +
83 + The counter32 type should not be used for configuration
84 + schema nodes. A default statement SHOULD NOT be used in
85 + combination with the type counter32.
86 +
87 + In the value set and its semantics, this type is equivalent
88 + to the Counter32 type of the SMIv2.";
89 + reference
90 + "RFC 2578: Structure of Management Information Version 2
91 + (SMIv2)";
92 +
93 + }
94 +
95 + typedef zero-based-counter32 {
96 + type counter32;
97 + default "0";
98 + description
99 + "The zero-based-counter32 type represents a counter32
100 + that has the defined 'initial' value zero.
101 +
102 + A schema node of this type will be set to zero (0) on creation
103 + and will thereafter increase monotonically until it reaches
104 + a maximum value of 2^32-1 (4294967295 decimal), when it
105 + wraps around and starts increasing again from zero.
106 +
107 + Provided that an application discovers a new schema node
108 + of this type within the minimum time to wrap, it can use the
109 + 'initial' value as a delta. It is important for a management
110 + station to be aware of this minimum time and the actual time
111 + between polls, and to discard data if the actual time is too
112 + long or there is no defined minimum time.
113 +
114 + In the value set and its semantics, this type is equivalent
115 + to the ZeroBasedCounter32 textual convention of the SMIv2.";
116 + reference
117 + "RFC 4502: Remote Network Monitoring Management Information
118 + Base Version 2";
119 +
120 + }
121 +
122 + typedef counter64 {
123 + type uint64;
124 + description
125 + "The counter64 type represents a non-negative integer
126 + that monotonically increases until it reaches a
127 + maximum value of 2^64-1 (18446744073709551615 decimal),
128 + when it wraps around and starts increasing again from zero.
129 +
130 + Counters have no defined 'initial' value, and thus, a
131 + single value of a counter has (in general) no information
132 + content. Discontinuities in the monotonically increasing
133 + value normally occur at re-initialization of the
134 + management system, and at other times as specified in the
135 + description of a schema node using this type. If such
136 + other times can occur, for example, the creation of
137 + a schema node of type counter64 at times other than
138 + re-initialization, then a corresponding schema node
139 + should be defined, with an appropriate type, to indicate
140 + the last discontinuity.
141 +
142 + The counter64 type should not be used for configuration
143 + schema nodes. A default statement SHOULD NOT be used in
144 + combination with the type counter64.
145 +
146 + In the value set and its semantics, this type is equivalent
147 + to the Counter64 type of the SMIv2.";
148 + reference
149 + "RFC 2578: Structure of Management Information Version 2
150 + (SMIv2)";
151 +
152 + }
153 +
154 + typedef zero-based-counter64 {
155 + type counter64;
156 + default "0";
157 + description
158 + "The zero-based-counter64 type represents a counter64 that
159 + has the defined 'initial' value zero.
160 +
161 +
162 +
163 +
164 + A schema node of this type will be set to zero (0) on creation
165 + and will thereafter increase monotonically until it reaches
166 + a maximum value of 2^64-1 (18446744073709551615 decimal),
167 + when it wraps around and starts increasing again from zero.
168 +
169 + Provided that an application discovers a new schema node
170 + of this type within the minimum time to wrap, it can use the
171 + 'initial' value as a delta. It is important for a management
172 + station to be aware of this minimum time and the actual time
173 + between polls, and to discard data if the actual time is too
174 + long or there is no defined minimum time.
175 +
176 + In the value set and its semantics, this type is equivalent
177 + to the ZeroBasedCounter64 textual convention of the SMIv2.";
178 + reference
179 + "RFC 2856: Textual Conventions for Additional High Capacity
180 + Data Types";
181 +
182 + }
183 +
184 + typedef gauge32 {
185 + type uint32;
186 + description
187 + "The gauge32 type represents a non-negative integer, which
188 + may increase or decrease, but shall never exceed a maximum
189 + value, nor fall below a minimum value. The maximum value
190 + cannot be greater than 2^32-1 (4294967295 decimal), and
191 + the minimum value cannot be smaller than 0. The value of
192 + a gauge32 has its maximum value whenever the information
193 + being modeled is greater than or equal to its maximum
194 + value, and has its minimum value whenever the information
195 + being modeled is smaller than or equal to its minimum value.
196 + If the information being modeled subsequently decreases
197 + below (increases above) the maximum (minimum) value, the
198 + gauge32 also decreases (increases).
199 +
200 + In the value set and its semantics, this type is equivalent
201 + to the Gauge32 type of the SMIv2.";
202 + reference
203 + "RFC 2578: Structure of Management Information Version 2
204 + (SMIv2)";
205 +
206 + }
207 +
208 + typedef gauge64 {
209 + type uint64;
210 + description
211 + "The gauge64 type represents a non-negative integer, which
212 + may increase or decrease, but shall never exceed a maximum
213 + value, nor fall below a minimum value. The maximum value
214 + cannot be greater than 2^64-1 (18446744073709551615), and
215 + the minimum value cannot be smaller than 0. The value of
216 + a gauge64 has its maximum value whenever the information
217 + being modeled is greater than or equal to its maximum
218 + value, and has its minimum value whenever the information
219 + being modeled is smaller than or equal to its minimum value.
220 + If the information being modeled subsequently decreases
221 + below (increases above) the maximum (minimum) value, the
222 + gauge64 also decreases (increases).
223 +
224 + In the value set and its semantics, this type is equivalent
225 + to the CounterBasedGauge64 SMIv2 textual convention defined
226 + in RFC 2856";
227 + reference
228 + "RFC 2856: Textual Conventions for Additional High Capacity
229 + Data Types";
230 +
231 + }
232 +
233 + typedef object-identifier {
234 + type string {
235 + pattern
236 + '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))(\.(0|([1-9]\d*)))*';
237 + }
238 + description
239 + "The object-identifier type represents administratively
240 + assigned names in a registration-hierarchical-name tree.
241 +
242 + Values of this type are denoted as a sequence of numerical
243 + non-negative sub-identifier values. Each sub-identifier
244 + value MUST NOT exceed 2^32-1 (4294967295). Sub-identifiers
245 + are separated by single dots and without any intermediate
246 + whitespace.
247 +
248 + The ASN.1 standard restricts the value space of the first
249 + sub-identifier to 0, 1, or 2. Furthermore, the value space
250 + of the second sub-identifier is restricted to the range
251 + 0 to 39 if the first sub-identifier is 0 or 1. Finally,
252 + the ASN.1 standard requires that an object identifier
253 + has always at least two sub-identifiers. The pattern
254 + captures these restrictions.
255 +
256 + Although the number of sub-identifiers is not limited,
257 + module designers should realize that there may be
258 + implementations that stick with the SMIv2 limit of 128
259 + sub-identifiers.
260 +
261 + This type is a superset of the SMIv2 OBJECT IDENTIFIER type
262 + since it is not restricted to 128 sub-identifiers. Hence,
263 + this type SHOULD NOT be used to represent the SMIv2 OBJECT
264 + IDENTIFIER type; the object-identifier-128 type SHOULD be
265 + used instead.";
266 + reference
267 + "ISO9834-1: Information technology -- Open Systems
268 + Interconnection -- Procedures for the operation of OSI
269 + Registration Authorities: General procedures and top
270 + arcs of the ASN.1 Object Identifier tree";
271 +
272 + }
273 +
274 + typedef object-identifier-128 {
275 + type object-identifier {
276 + pattern '\d*(\.\d*){1,127}';
277 + }
278 + description
279 + "This type represents object-identifiers restricted to 128
280 + sub-identifiers.
281 +
282 + In the value set and its semantics, this type is equivalent
283 + to the OBJECT IDENTIFIER type of the SMIv2.";
284 + reference
285 + "RFC 2578: Structure of Management Information Version 2
286 + (SMIv2)";
287 +
288 + }
289 +
290 + typedef yang-identifier {
291 + type string {
292 + length "1..max";
293 + pattern '[a-zA-Z_][a-zA-Z0-9\-_.]*';
294 + pattern
295 + '.|..|[^xX].*|.[^mM].*|..[^lL].*';
296 + }
297 + description
298 + "A YANG identifier string as defined by the 'identifier'
299 + rule in Section 12 of RFC 6020. An identifier must
300 + start with an alphabetic character or an underscore
301 + followed by an arbitrary sequence of alphabetic or
302 + numeric characters, underscores, hyphens, or dots.
303 +
304 + A YANG identifier MUST NOT start with any possible
305 + combination of the lowercase or uppercase character
306 + sequence 'xml'.";
307 + reference
308 + "RFC 6020: YANG - A Data Modeling Language for the Network
309 + Configuration Protocol (NETCONF)";
310 +
311 + }
312 +
313 + typedef date-and-time {
314 + type string {
315 + pattern
316 + '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-]\d{2}:\d{2})';
317 + }
318 + description
319 + "The date-and-time type is a profile of the ISO 8601
320 + standard for representation of dates and times using the
321 + Gregorian calendar. The profile is defined by the
322 + date-time production in Section 5.6 of RFC 3339.
323 +
324 + The date-and-time type is compatible with the dateTime XML
325 + schema type with the following notable exceptions:
326 +
327 + (a) The date-and-time type does not allow negative years.
328 +
329 + (b) The date-and-time time-offset -00:00 indicates an unknown
330 + time zone (see RFC 3339) while -00:00 and +00:00 and Z
331 + all represent the same time zone in dateTime.
332 +
333 + (c) The canonical format (see below) of data-and-time values
334 + differs from the canonical format used by the dateTime XML
335 + schema type, which requires all times to be in UTC using
336 + the time-offset 'Z'.
337 +
338 + This type is not equivalent to the DateAndTime textual
339 + convention of the SMIv2 since RFC 3339 uses a different
340 + separator between full-date and full-time and provides
341 + higher resolution of time-secfrac.
342 +
343 + The canonical format for date-and-time values with a known time
344 + zone uses a numeric time zone offset that is calculated using
345 + the device's configured known offset to UTC time. A change of
346 + the device's offset to UTC time will cause date-and-time values
347 + to change accordingly. Such changes might happen periodically
348 + in case a server follows automatically daylight saving time
349 + (DST) time zone offset changes. The canonical format for
350 + date-and-time values with an unknown time zone (usually
351 + referring to the notion of local time) uses the time-offset
352 + -00:00.";
353 + reference
354 + "RFC 3339: Date and Time on the Internet: Timestamps
355 + RFC 2579: Textual Conventions for SMIv2
356 + XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
357 +
358 + }
359 +
360 + typedef timeticks {
361 + type uint32;
362 + description
363 + "The timeticks type represents a non-negative integer that
364 + represents the time, modulo 2^32 (4294967296 decimal), in
365 + hundredths of a second between two epochs. When a schema
366 + node is defined that uses this type, the description of
367 + the schema node identifies both of the reference epochs.
368 +
369 + In the value set and its semantics, this type is equivalent
370 + to the TimeTicks type of the SMIv2.";
371 + reference
372 + "RFC 2578: Structure of Management Information Version 2
373 + (SMIv2)";
374 +
375 + }
376 +
377 + typedef timestamp {
378 + type timeticks;
379 + description
380 + "The timestamp type represents the value of an associated
381 + timeticks schema node at which a specific occurrence
382 + happened. The specific occurrence must be defined in the
383 + description of any schema node defined using this type. When
384 + the specific occurrence occurred prior to the last time the
385 + associated timeticks attribute was zero, then the timestamp
386 + value is zero. Note that this requires all timestamp values
387 + to be reset to zero when the value of the associated timeticks
388 + attribute reaches 497+ days and wraps around to zero.
389 +
390 + The associated timeticks schema node must be specified
391 + in the description of any schema node using this type.
392 +
393 + In the value set and its semantics, this type is equivalent
394 + to the TimeStamp textual convention of the SMIv2.";
395 + reference
396 + "RFC 2579: Textual Conventions for SMIv2";
397 +
398 + }
399 +
400 + typedef phys-address {
401 + type string {
402 + pattern
403 + '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
404 + }
405 + description
406 + "Represents media- or physical-level addresses represented
407 + as a sequence octets, each octet represented by two hexadecimal
408 + numbers. Octets are separated by colons. The canonical
409 + representation uses lowercase characters.
410 +
411 + In the value set and its semantics, this type is equivalent
412 + to the PhysAddress textual convention of the SMIv2.";
413 + reference
414 + "RFC 2579: Textual Conventions for SMIv2";
415 +
416 + }
417 +
418 + typedef mac-address {
419 + type string {
420 + pattern
421 + '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
422 + }
423 + description
424 + "The mac-address type represents an IEEE 802 MAC address.
425 + The canonical representation uses lowercase characters.
426 +
427 + In the value set and its semantics, this type is equivalent
428 + to the MacAddress textual convention of the SMIv2.";
429 + reference
430 + "IEEE 802: IEEE Standard for Local and Metropolitan Area
431 + Networks: Overview and Architecture
432 + RFC 2579: Textual Conventions for SMIv2";
433 +
434 + }
435 +
436 + typedef xpath1.0 {
437 + type string;
438 + description
439 + "This type represents an XPATH 1.0 expression.
440 +
441 + When a schema node is defined that uses this type, the
442 + description of the schema node MUST specify the XPath
443 + context in which the XPath expression is evaluated.";
444 + reference
445 + "XPATH: XML Path Language (XPath) Version 1.0";
446 +
447 + }
448 +
449 + typedef hex-string {
450 + type string {
451 + pattern
452 + '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
453 + }
454 + description
455 + "A hexadecimal string with octets represented as hex digits
456 + separated by colons. The canonical representation uses
457 + lowercase characters.";
458 + }
459 +
460 + typedef uuid {
461 + type string {
462 + pattern
463 + '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
464 + }
465 + description
466 + "A Universally Unique IDentifier in the string representation
467 + defined in RFC 4122. The canonical representation uses
468 + lowercase characters.
469 +
470 + The following is an example of a UUID in string representation:
471 + f81d4fae-7dec-11d0-a765-00a0c91e6bf6
472 + ";
473 + reference
474 + "RFC 4122: A Universally Unique IDentifier (UUID) URN
475 + Namespace";
476 +
477 + }
478 +
479 + typedef dotted-quad {
480 + type string {
481 + pattern
482 + '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])';
483 + }
484 + description
485 + "An unsigned 32-bit number expressed in the dotted-quad
486 + notation, i.e., four octets written as decimal numbers
487 + and separated with the '.' (full stop) character.";
488 + }
489 + }
1 +module test {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type int32;
18 + type uint16;
19 + }
20 + }
21 +
22 +}
23 +
1 +module test {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type int32;
18 + type string;
19 + type uint16;
20 + }
21 + }
22 +
23 +}
24 +
1 +module test2 {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type int64;
18 + type string;
19 + type uint16;
20 + }
21 + }
22 +
23 +}
24 +
1 +module test {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type int32;
18 + type uint16;
19 + type uint32;
20 + type int64;
21 + }
22 + }
23 +
24 +}
25 +
1 +module test {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type string;
18 + type int32;
19 + type uint16;
20 + type uint32;
21 + type int64;
22 + }
23 + }
24 +
25 +}
26 +
1 +module test {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type int64;
18 + type uint32;
19 + }
20 + }
21 +
22 +}
23 +
1 +module test {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type uint16;
18 + type int32;
19 + }
20 + }
21 +
22 +}
23 +
1 +module test {
2 + namespace "test:test";
3 + prefix test ;
4 +
5 + organization "";
6 + contact "";
7 +
8 + description
9 + "Defines basic service types for L3VPN service.";
10 +
11 + revision "2015-12-16" {
12 + reference "";
13 + }
14 +
15 + leaf leaf1 {
16 + type union {
17 + type uint32;
18 + type int64;
19 + }
20 + }
21 +
22 +}
23 +