removed code duplication in translator, and addressed review comments

Change-Id: I27767a81c4bf279c80d2b98192f75f8f507b4457
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/CopyrightHeader.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/CopyrightHeader.java
index 3ba2fc6..27f1036 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/CopyrightHeader.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/CopyrightHeader.java
@@ -24,9 +24,10 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
-import static org.slf4j.LoggerFactory.getLogger;
 import org.slf4j.Logger;
 
+import static org.slf4j.LoggerFactory.getLogger;
+
 /**
  * Provides the license header for the generated files.
  */
@@ -48,7 +49,7 @@
      * Returns copyright file header.
      *
      * @return copyright file header
-     * @throws IOException when fails to parse copyright header.
+     * @throws IOException when fails to parse copyright header
      */
     public static String getCopyrightHeader() throws IOException {
         return copyrightHeader;
@@ -66,7 +67,7 @@
     /**
      * parse Copyright to the temporary file.
      *
-     * @throws IOException when fails to get the copyright header.
+     * @throws IOException when fails to get the copyright header
      */
     public static void parseCopyrightHeader() throws IOException {
 
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
index 8a537f5..7181a62 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
@@ -24,7 +24,6 @@
 import java.io.PrintWriter;
 
 import org.onosproject.yangutils.translator.CachedFileHandle;
-import org.onosproject.yangutils.translator.GeneratedFileType;
 import org.onosproject.yangutils.translator.tojava.CachedJavaFileHandle;
 import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
 import org.onosproject.yangutils.utils.UtilConstants;
@@ -42,8 +41,8 @@
     /**
      * Check if the package directory structure created.
      *
-     * @param pkg Package to check if it is created.
-     * @return existence status of package.
+     * @param pkg Package to check if it is created
+     * @return existence status of package
      */
     public static boolean doesPackageExist(String pkg) {
         File pkgDir = new File(pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH));
@@ -76,13 +75,16 @@
     /**
      * Create a java source file in the specified package.
      *
-     * @param pkg java package under which the interface file needs to be created.
-     * @param yangName YANG name of the node for which java file needs to be created.
-     * @param types types of files to be created.
-     * @throws IOException when fails to create interface file.
-     * @return the cached java file handle, which can be used to further add methods.
+     * @param pkg java package under which the interface file needs to be
+     *            created
+     * @param yangName YANG name of the node for which java file needs to be
+     *            created
+     * @param types types of files to be created
+     * @throws IOException when fails to create interface file
+     * @return the cached java file handle, which can be used to further add
+     *         methods
      */
-    public static CachedFileHandle createSourceFiles(String pkg, String yangName, GeneratedFileType types)
+    public static CachedFileHandle createSourceFiles(String pkg, String yangName, int types)
             throws IOException {
         yangName = JavaIdentifierSyntax.getCamelCase(yangName);
         CachedFileHandle handler = new CachedJavaFileHandle(pkg, yangName, types);
@@ -95,10 +97,10 @@
      * file.
      *
      * @param toAppend destination file in which the contents of source file is
-     *            appended.
+     *            appended
      * @param srcFile source file from which data is read and added to to append
-     *            file.
-     * @throws IOException any IO errors.
+     *            file
+     * @throws IOException any IO errors
      */
     public static void appendFileContents(File toAppend, File srcFile) throws IOException {
 
@@ -109,8 +111,8 @@
     /**
      * Reads file and convert it to string.
      *
-     * @param toAppend file to be converted.
-     * @return string of file.
+     * @param toAppend file to be converted
+     * @return string of file
      * @throws IOException when fails to convert to string
      */
     private static String readAppendFile(String toAppend) throws IOException {
@@ -134,8 +136,8 @@
      * Insert content to the generated file.
      *
      * @param inputFile input file
-     * @param contentTobeAdded content to be appended to the file.
-     * @throws IOException when fails to append content to the file.
+     * @param contentTobeAdded content to be appended to the file
+     * @throws IOException when fails to append content to the file
      */
     public static void insertStringInFile(File inputFile, String contentTobeAdded) throws IOException {
         FileWriter fileWriter = new FileWriter(inputFile, true);
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
index 4be5037..c2f170c 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
@@ -91,7 +91,7 @@
      *
      * @param type java doc type
      * @param name name of the YangNode
-     * @return javadocs.
+     * @return javadocs
      */
     public static String getJavaDoc(JavaDocType type, String name) {
         name = JavaIdentifierSyntax.getCamelCase(name);
@@ -127,12 +127,12 @@
      * @return javaDocs
      */
     private static String generateForGetters(String attribute) {
-        return (UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
+        return UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
                 + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_GETTERS + attribute
                 + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
                 + UtilConstants.NEW_LINE_ESTRIC + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_RETURN
                 + attribute + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
-                + UtilConstants.JAVA_DOC_END_LINE);
+                + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
@@ -142,58 +142,58 @@
      * @return javaDocs
      */
     private static String generateForSetters(String attribute) {
-        return (UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
+        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
                 + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_SETTERS + attribute
                 + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
                 + UtilConstants.NEW_LINE_ESTRIC + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_PARAM
                 + attribute + UtilConstants.SPACE + attribute + UtilConstants.NEW_LINE
                 + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_RETURN + UtilConstants.BUILDER_OBJECT
                 + attribute + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
-                + UtilConstants.JAVA_DOC_END_LINE);
+                + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
      * Generate javaDocs for the impl class.
      *
      * @param className class name
-     * @return javaDocs.
+     * @return javaDocs
      */
     private static String generateForImplClass(String className) {
-        return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.IMPL_CLASS_JAVA_DOC + className + UtilConstants.PERIOD
-                + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE);
+        return UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.IMPL_CLASS_JAVA_DOC + className + UtilConstants.PERIOD
+                + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
      * Generate javaDocs for the builder class.
      *
      * @param className class name
-     * @return javaDocs.
+     * @return javaDocs
      */
     private static String generateForBuilderClass(String className) {
-        return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.BUILDER_CLASS_JAVA_DOC + className
-                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE);
+        return UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.BUILDER_CLASS_JAVA_DOC + className
+                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
      * Generate javaDoc for the interface.
      *
      * @param interfaceName interface name
-     * @return javaDocs.
+     * @return javaDocs
      */
     private static String generateForInterface(String interfaceName) {
-        return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.INTERFACE_JAVA_DOC + interfaceName
-                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE);
+        return UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.INTERFACE_JAVA_DOC + interfaceName
+                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
      * Generate javaDoc for the builder interface.
      *
      * @param builderforName builder for name
-     * @return javaDocs.
+     * @return javaDocs
      */
     private static String generateForBuilderInterface(String builderforName) {
-        return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.BUILDER_INTERFACE_JAVA_DOC + builderforName
-                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE);
+        return UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.BUILDER_INTERFACE_JAVA_DOC + builderforName
+                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
@@ -203,8 +203,8 @@
      * @return javaDocs
      */
     private static String generateForPackage(String packageName) {
-        return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.PACKAGE_INFO_JAVADOC + packageName
-                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE);
+        return UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.PACKAGE_INFO_JAVADOC + packageName
+                + UtilConstants.PERIOD + UtilConstants.NEW_LINE + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
@@ -213,38 +213,38 @@
      * @return javaDocs
      */
     private static String generateForDefaultConstructors() {
-        return (UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_DEFAULT_CONSTRUCTOR
-                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_END_LINE);
+        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_DEFAULT_CONSTRUCTOR
+                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
      * Generate javaDocs for constructor with parameters.
      *
-     * @param params list of parameters
      * @param className class name
      * @return javaDocs
      */
     private static String generateForConstructors(String className) {
-        return (UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+        return UtilConstants.JAVA_DOC_FIRST_LINE + UtilConstants.FOUR_SPACE_INDENTATION
                 + UtilConstants.JAVA_DOC_CONSTRUCTOR + className + UtilConstants.IMPL + UtilConstants.PERIOD
                 + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.NEW_LINE_ESTRIC
                 + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_PARAM
-                + (className.substring(0, 1).toLowerCase() + className.substring(1)) + UtilConstants.OBJECT
+                + className.substring(0, 1).toLowerCase() + className.substring(1) + UtilConstants.OBJECT
                 + UtilConstants.SPACE + UtilConstants.BUILDER_OBJECT + UtilConstants.SPACE + className
-                + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_END_LINE);
+                + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_END_LINE;
     }
 
     /**
      * Generate javaDocs for build.
      *
+     * @param buildName builder name
      * @return javaDocs
      */
     private static String generateForBuild(String buildName) {
-        return (UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
+        return UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
                 + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_BUILD + buildName + UtilConstants.PERIOD
                 + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.NEW_LINE_ESTRIC
                 + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_RETURN
                 + UtilConstants.JAVA_DOC_BUILD_RETURN + buildName + UtilConstants.PERIOD + UtilConstants.NEW_LINE
-                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_END_LINE);
+                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_END_LINE;
     }
 }
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/TempDataStore.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/TempDataStore.java
index 63cba97..b3e9ff5 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/TempDataStore.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/TempDataStore.java
@@ -33,7 +33,8 @@
 import java.util.List;
 
 /**
- * Provides storage for Temp data while traversing data model tree for code generation.
+ * Provides storage for Temp data while traversing data model tree for code
+ * generation.
  */
 public final class TempDataStore {
 
@@ -130,7 +131,7 @@
      * @param data data to be stored
      * @param type type of Temp data store
      * @param className class name
-     * @throws IOException when fails to create a Temp data file.
+     * @throws IOException when fails to create a Temp data file
      */
     public static void setTempData(String data, TempDataStoreType type, String className) throws IOException {
 
@@ -170,11 +171,11 @@
      * Get the Temp data.
      *
      * @param type type of Temp data store
-     * @param className name of the class.
-     * @return list of attribute info.
-     * @throws IOException when fails to read from the file.
-     * @throws ClassNotFoundException when class is missing.
-     * @throws FileNotFoundException when file is missing.
+     * @param className name of the class
+     * @return list of attribute info
+     * @throws IOException when fails to read from the file
+     * @throws ClassNotFoundException when class is missing
+     * @throws FileNotFoundException when file is missing
      */
     public static List<String> getTempData(TempDataStoreType type, String className)
             throws IOException, FileNotFoundException, ClassNotFoundException {
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java
index bb94b35..98e0444 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java
@@ -37,10 +37,10 @@
      * Returns the list of java files.
      *
      * @param root specified directory
-     * @return list of java files.
-     * @throws NullPointerException when no files are there.
+     * @return list of java files
+     * @throws NullPointerException when no files are there
      * @throws IOException when files get deleted while performing the
-     *             operations.
+     *             operations
      */
     public static List<String> getJavaFiles(String root) throws NullPointerException, IOException {
         return getFiles(root, ".java");
@@ -50,10 +50,10 @@
      * Returns the list of YANG files.
      *
      * @param root specified directory
-     * @return list of YANG files.
-     * @throws NullPointerException when no files are there.
+     * @return list of YANG files
+     * @throws NullPointerException when no files are there
      * @throws IOException when files get deleted while performing the
-     *             operations.
+     *             operations
      */
     public static List<String> getYangFiles(String root) throws NullPointerException, IOException {
         return getFiles(root, ".yang");
@@ -63,12 +63,13 @@
      * Returns the list of required files.
      *
      * @param root specified directory
-     * @param extension file extension.
-     * @return list of required files.
+     * @param extension file extension
+     * @return list of required files
      * @throws IOException when files get deleted while performing the
-     *             operations.
+     *             operations
+     * @throws NullPointerException null pointer access
      */
-    public static List<String> getFiles(String root, String extension) throws  NullPointerException, IOException {
+    public static List<String> getFiles(String root, String extension) throws NullPointerException, IOException {
         List<String> store = new LinkedList<>();
         Stack<String> stack = new Stack<>();
         stack.push(root);
diff --git a/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java b/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
index 3357000..a0aba1f 100644
--- a/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
+++ b/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
@@ -22,15 +22,14 @@
 import java.io.IOException;
 import java.util.List;
 
-import org.sonatype.plexus.build.incremental.BuildContext;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.model.Resource;
-
-import org.onosproject.yangutils.utils.UtilConstants;
 import org.apache.commons.io.FileUtils;
+import org.apache.maven.model.Resource;
+import org.apache.maven.project.MavenProject;
+import org.onosproject.yangutils.utils.UtilConstants;
+import org.slf4j.Logger;
+import org.sonatype.plexus.build.incremental.BuildContext;
 
 import static org.slf4j.LoggerFactory.getLogger;
-import org.slf4j.Logger;
 
 /**
  * Provides common utility functionalities for code generation.
@@ -64,7 +63,7 @@
      * @param path directory path
      * @param classInfo class info for the package
      * @param pack package of the directory
-     * @throws IOException when fails to create package info file.
+     * @throws IOException when fails to create package info file
      */
     public static void addPackageInfo(File path, String classInfo, String pack) throws IOException {
 
@@ -92,7 +91,7 @@
     /**
      * Cleans the generated directory if already exist in source folder.
      *
-     * @param baseDir generated directory in previous build.
+     * @param baseDir generated directory in previous build
      */
     public static void clean(String baseDir) {
         File generatedDirectory = new File(baseDir + File.separator + UtilConstants.YANG_GEN_DIR);