YANG Translator optimization
Change-Id: Ie6a6b9d371a4fc5fd973cf56d6f3c7b44a3146ba
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
index 4d8180e..ab8ee5c 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
@@ -16,8 +16,7 @@
package org.onosproject.yangutils.translator.tojava.utils;
-import org.onosproject.yangutils.translator.GeneratedFileType;
-import org.onosproject.yangutils.translator.tojava.ImportInfo;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
import org.onosproject.yangutils.utils.UtilConstants;
/**
@@ -51,7 +50,8 @@
* @return the textual java code information corresponding to the import
* list
*/
- public static String getImportText(ImportInfo importInfo) {
+ public static String getImportText(JavaQualifiedTypeInfo importInfo) {
+
return UtilConstants.IMPORT + importInfo.getPkgInfo() + UtilConstants.PERIOD + importInfo.getClassInfo()
+ UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE;
}
@@ -65,6 +65,7 @@
* @return corresponding textual java code information
*/
public static String getJavaClassDefStart(int genFileTypes, String yangName) {
+
/*
* get the camel case name for java class / interface.
*/
@@ -90,24 +91,24 @@
if (!isList) {
if (javaAttributeTypePkg != null) {
attributeDefination = attributeDefination
- + javaAttributeTypePkg + ".";
+ + javaAttributeTypePkg + UtilConstants.PERIOD;
}
attributeDefination = attributeDefination
+ javaAttributeType
+ UtilConstants.SPACE
+ javaAttributeName
- + UtilConstants.SEMI_COLAN;
+ + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE;
} else {
attributeDefination = attributeDefination + UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET;
if (javaAttributeTypePkg != null) {
attributeDefination = attributeDefination
- + javaAttributeTypePkg + ".";
+ + javaAttributeTypePkg + UtilConstants.PERIOD;
}
attributeDefination = attributeDefination
+ javaAttributeType + UtilConstants.DIAMOND_CLOSE_BRACKET + UtilConstants.SPACE
- + javaAttributeName + UtilConstants.SEMI_COLAN;
+ + javaAttributeName + UtilConstants.SUFIX_S + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE;
}
return attributeDefination;
}
@@ -119,6 +120,7 @@
* @return list attribute string
*/
public static String getListAttribute(String type) {
+
return UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET + type + UtilConstants.DIAMOND_CLOSE_BRACKET;
}
@@ -126,23 +128,11 @@
* Based on the file type and the YANG name of the file, generate the class
* / interface definition close.
*
- * @param genFileTypes type of file being generated
- * @param yangName YANG name
* @return corresponding textual java code information
*/
- public static String getJavaClassDefClose(int genFileTypes, String yangName) {
+ public static String getJavaClassDefClose() {
- if ((genFileTypes & GeneratedFileType.INTERFACE_MASK) != 0) {
-
- return UtilConstants.CLOSE_CURLY_BRACKET;
- } else if ((genFileTypes & GeneratedFileType.BUILDER_CLASS_MASK) != 0) {
-
- return UtilConstants.CLOSE_CURLY_BRACKET;
- } else if ((genFileTypes & GeneratedFileType.GENERATE_TYPEDEF_CLASS) != 0) {
-
- return UtilConstants.CLOSE_CURLY_BRACKET;
- }
- return null;
+ return UtilConstants.CLOSE_CURLY_BRACKET;
}
}