ST defect fixes and review comments fixes

Change-Id: Ib8c56a88c19cd9aa23918d0f9e37c89e74cb0d13
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
index 70869b2..138b7d4 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
@@ -79,7 +79,7 @@
         } else if (type.equals(YangDataTypes.INSTANCE_IDENTIFIER)) {
             //TODO:INSTANCE_IDENTIFIER
         } else if (type.equals(YangDataTypes.DERIVED)) {
-            //TODO:DERIVED
+            return yangType.getDataTypeName();
         }
         return null;
     }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
index 41a3117..58a0896 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
@@ -56,6 +56,9 @@
         } else if ((genFileTypes & GeneratedFileType.BUILDER_INTERFACE_MASK) != 0) {
 
             return getBuilderInterfaceDefinition(yangName);
+        } else if ((genFileTypes & GeneratedFileType.GENERATE_TYPEDEF_CLASS) != 0) {
+
+            return getTypeDefClassDefinition(yangName);
         }
         return null;
     }
@@ -94,7 +97,7 @@
 
         return UtilConstants.PUBLIC + UtilConstants.SPACE + UtilConstants.CLASS + UtilConstants.SPACE + yangName
                 + UtilConstants.BUILDER + UtilConstants.SPACE + UtilConstants.IMPLEMENTS + UtilConstants.SPACE
-                + yangName + UtilConstants.PERIOD + UtilConstants.BUILDER + UtilConstants.SPACE
+                + yangName + UtilConstants.PERIOD + yangName + UtilConstants.BUILDER + UtilConstants.SPACE
                 + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE;
     }
 
@@ -108,8 +111,22 @@
 
         return UtilConstants.PUBLIC + UtilConstants.SPACE + UtilConstants.FINAL + UtilConstants.SPACE
                 + UtilConstants.CLASS + UtilConstants.SPACE + yangName + UtilConstants.IMPL + UtilConstants.SPACE
-                + UtilConstants.IMPLEMENTS + UtilConstants.SPACE + yangName + UtilConstants.OPEN_CURLY_BRACKET
+                + UtilConstants.IMPLEMENTS + UtilConstants.SPACE + yangName + UtilConstants.SPACE
+                + UtilConstants.OPEN_CURLY_BRACKET
                 + UtilConstants.SPACE + UtilConstants.NEW_LINE;
     }
 
+    /**
+     * Returns typeDef file class definition.
+     *
+     * @param yangName file name
+     * @return definition
+     */
+    private static String getTypeDefClassDefinition(String yangName) {
+
+        return UtilConstants.PUBLIC + UtilConstants.SPACE + UtilConstants.FINAL + UtilConstants.SPACE
+                + UtilConstants.CLASS + UtilConstants.SPACE + yangName + UtilConstants.SPACE
+                + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.SPACE + UtilConstants.NEW_LINE;
+    }
+
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
index 4d6a475..4d8180e 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
@@ -78,25 +78,37 @@
      * @param javaAttributeTypePkg Package of the attribute type
      * @param javaAttributeType java attribute type
      * @param javaAttributeName name of the attribute
+     * @param isList is list attribute
      * @return the textual java code for attribute definition in class
      */
     public static String getJavaAttributeDefination(String javaAttributeTypePkg, String javaAttributeType,
-            String javaAttributeName) {
+            String javaAttributeName, boolean isList) {
 
         String attributeDefination = UtilConstants.PRIVATE
                 + UtilConstants.SPACE;
 
-        if (javaAttributeTypePkg != null) {
+        if (!isList) {
+            if (javaAttributeTypePkg != null) {
+                attributeDefination = attributeDefination
+                        + javaAttributeTypePkg + ".";
+            }
+
             attributeDefination = attributeDefination
-                    + javaAttributeTypePkg + ".";
+                    + javaAttributeType
+                    + UtilConstants.SPACE
+                    + javaAttributeName
+                    + UtilConstants.SEMI_COLAN;
+        } else {
+            attributeDefination = attributeDefination + UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET;
+            if (javaAttributeTypePkg != null) {
+                attributeDefination = attributeDefination
+                        + javaAttributeTypePkg + ".";
+            }
+
+            attributeDefination = attributeDefination
+                    + javaAttributeType + UtilConstants.DIAMOND_CLOSE_BRACKET + UtilConstants.SPACE
+                    + javaAttributeName + UtilConstants.SEMI_COLAN;
         }
-
-        attributeDefination = attributeDefination
-                + javaAttributeType
-                + UtilConstants.SPACE
-                + javaAttributeName
-                + UtilConstants.SEMI_COLAN;
-
         return attributeDefination;
     }
 
@@ -126,6 +138,9 @@
         } 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;
     }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index ff275ae..0ae81f7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -16,26 +16,28 @@
 
 package org.onosproject.yangutils.translator.tojava.utils;
 
+import static org.onosproject.yangutils.translator.GeneratedFileType.BUILDER_CLASS_MASK;
+import static org.onosproject.yangutils.translator.GeneratedFileType.BUILDER_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.GeneratedFileType.GENERATE_TYPEDEF_CLASS;
+import static org.onosproject.yangutils.translator.GeneratedFileType.IMPL_CLASS_MASK;
+import static org.onosproject.yangutils.translator.GeneratedFileType.INTERFACE_MASK;
+import static org.slf4j.LoggerFactory.getLogger;
+
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.io.FileUtils;
+import org.onosproject.yangutils.translator.CachedFileHandle;
 import org.onosproject.yangutils.translator.tojava.AttributeInfo;
 import org.onosproject.yangutils.utils.UtilConstants;
 import org.onosproject.yangutils.utils.io.impl.CopyrightHeader;
 import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
 import org.onosproject.yangutils.utils.io.impl.JavaDocGen;
 import org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType;
-import org.onosproject.yangutils.utils.io.impl.TempDataStore;
-import org.onosproject.yangutils.utils.io.impl.TempDataStore.TempDataStoreType;
 import org.slf4j.Logger;
 
-import static org.onosproject.yangutils.translator.GeneratedFileType.BUILDER_CLASS_MASK;
-import static org.onosproject.yangutils.translator.GeneratedFileType.BUILDER_INTERFACE_MASK;
-import static org.onosproject.yangutils.translator.GeneratedFileType.IMPL_CLASS_MASK;
-import static org.onosproject.yangutils.translator.GeneratedFileType.INTERFACE_MASK;
-import static org.slf4j.LoggerFactory.getLogger;
-
 /**
  * Generates java file.
  */
@@ -55,10 +57,11 @@
      * @param fileName file name
      * @param filePath file package path
      * @param extension file extension
+     * @param handle cached file handle
      * @return file object
      */
-    public static File getFileObject(String filePath, String fileName, String extension) {
-        return new File(UtilConstants.YANG_GEN_DIR + filePath + File.separator + fileName + extension);
+    public static File getFileObject(String filePath, String fileName, String extension, CachedFileHandle handle) {
+        return new File(handle.getCodeGenFilePath() + filePath + File.separator + fileName + extension);
     }
 
     /**
@@ -69,17 +72,18 @@
      * @param imports imports for the file
      * @param attrList attribute info
      * @param pkg generated file package
+     * @param handle cached file handle
      * @return interface file
      * @throws IOException when fails to write in file
      */
     public static File generateInterfaceFile(File file, String className, List<String> imports,
-            List<AttributeInfo> attrList, String pkg) throws IOException {
-
+            List<AttributeInfo> attrList, String pkg, CachedFileHandle handle) throws IOException {
+        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
         initiateFile(file, className, INTERFACE_MASK, imports, pkg);
 
-        List<String> methods;
+        List<String> methods = new ArrayList<>();
         try {
-            methods = TempDataStore.getTempData(TempDataStoreType.GETTER_METHODS, className);
+            methods.add(handle.getTempData(TempDataStoreTypes.GETTER_METHODS, className, path));
         } catch (ClassNotFoundException | IOException e) {
             log.info("There is no attribute info of " + className + " YANG file in the temporary files.");
             throw new IOException("Fail to read data from temp file.");
@@ -101,17 +105,19 @@
      * @param className class name
      * @param pkg generated file package
      * @param attrList attribute info
+     * @param handle cached file handle
      * @return builder interface file
      * @throws IOException when fails to write in file
      */
     public static File generateBuilderInterfaceFile(File file, String className, String pkg,
-            List<AttributeInfo> attrList) throws IOException {
-
+            List<AttributeInfo> attrList, CachedFileHandle handle) throws IOException {
+        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
         initiateFile(file, className, BUILDER_INTERFACE_MASK, null, pkg);
-        List<String> methods;
+        List<String> methods = new ArrayList<>();
+
         try {
-            methods = TempDataStore.getTempData(TempDataStoreType.BUILDER_INTERFACE_METHODS,
-                    className + UtilConstants.BUILDER + UtilConstants.INTERFACE);
+            methods.add(handle.getTempData(TempDataStoreTypes.GETTER_METHODS, className, path));
+            methods.add(handle.getTempData(TempDataStoreTypes.SETTER_METHODS, className, path));
         } catch (ClassNotFoundException | IOException e) {
             log.info("There is no attribute info of " + className + " YANG file in the temporary files.");
             throw new IOException("Fail to read data from temp file.");
@@ -126,7 +132,7 @@
          * Add getters and setters in builder interface.
          */
         for (String method : methods) {
-            appendMethod(file, UtilConstants.FOUR_SPACE_INDENTATION + method + UtilConstants.NEW_LINE);
+            appendMethod(file, UtilConstants.FOUR_SPACE_INDENTATION + method);
         }
 
         insert(file, UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE);
@@ -141,20 +147,21 @@
      * @param imports imports for the file
      * @param pkg generated file package
      * @param attrList attribute info
+     * @param handle cached file handle
      * @return builder class file
      * @throws IOException when fails to write in file
      */
     public static File generateBuilderClassFile(File file, String className, List<String> imports, String pkg,
-            List<AttributeInfo> attrList) throws IOException {
-
+            List<AttributeInfo> attrList, CachedFileHandle handle) throws IOException {
+        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
         initiateFile(file, className, BUILDER_CLASS_MASK, imports, pkg);
 
         /**
          * Add attribute strings.
          */
-        List<String> attributes;
+        List<String> attributes = new ArrayList<>();
         try {
-            attributes = TempDataStore.getTempData(TempDataStoreType.ATTRIBUTE, className);
+            attributes.add(handle.getTempData(TempDataStoreTypes.ATTRIBUTE, className, path));
         } catch (ClassNotFoundException | IOException e) {
             log.info("There is no attribute info of " + className + " YANG file in the temporary files.");
             throw new IOException("Fail to read data from temp file.");
@@ -165,11 +172,11 @@
         for (String attribute : attributes) {
             insert(file, UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + attribute);
         }
-        insert(file, UtilConstants.NEW_LINE);
 
-        List<String> methods;
+        List<String> methods = new ArrayList<>();
         try {
-            methods = TempDataStore.getTempData(TempDataStoreType.BUILDER_METHODS, className + UtilConstants.BUILDER);
+            methods.add(handle.getTempData(TempDataStoreTypes.GETTER_METHODS_IMPL, className, path));
+            methods.add(handle.getTempData(TempDataStoreTypes.SETTER_METHODS_IMPL, className, path));
         } catch (ClassNotFoundException | IOException e) {
             log.info("There is no attribute info of " + className + " YANG file in the temporary files.");
             throw new IOException("Fail to read data from temp file.");
@@ -179,7 +186,8 @@
          * Add default constructor and build method impl.
          */
         methods.add(UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
-                + MethodsGenerator.getDefaultConstructorString(BUILDER_CLASS_MASK, className));
+                + MethodsGenerator.getDefaultConstructorString(className + UtilConstants.BUILDER,
+                        UtilConstants.PUBLIC));
         methods.add(MethodsGenerator.getBuildString(className));
 
         /**
@@ -198,17 +206,19 @@
      * @param className class name
      * @param pkg generated file package
      * @param attrList attribute's info
+     * @param handle cached file handle
      * @return impl class file
      * @throws IOException when fails to write in file
      */
-    public static File generateImplClassFile(File file, String className, String pkg, List<AttributeInfo> attrList)
-            throws IOException {
+    public static File generateImplClassFile(File file, String className, String pkg, List<AttributeInfo> attrList,
+            CachedFileHandle handle)
+                    throws IOException {
+        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
+        initiateFile(file, className, IMPL_CLASS_MASK, null, path);
 
-        initiateFile(file, className, IMPL_CLASS_MASK, null, pkg);
-
-        List<String> attributes;
+        List<String> attributes = new ArrayList<>();
         try {
-            attributes = TempDataStore.getTempData(TempDataStoreType.ATTRIBUTE, className);
+            attributes.add(handle.getTempData(TempDataStoreTypes.ATTRIBUTE, className, path));
         } catch (ClassNotFoundException | IOException e) {
             log.info("There is no attribute info of " + className + " YANG file in the temporary files.");
             throw new IOException("Fail to read data from temp file.");
@@ -220,24 +230,34 @@
         for (String attribute : attributes) {
             insert(file, UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + attribute);
         }
-        insert(file, UtilConstants.NEW_LINE);
 
-        List<String> methods;
+        List<String> methods = new ArrayList<>();
         try {
-            methods = TempDataStore.getTempData(TempDataStoreType.IMPL_METHODS, className + UtilConstants.IMPL);
+
+            methods.add(handle.getTempData(TempDataStoreTypes.GETTER_METHODS_IMPL, className, path));
+
+            methods.add(getConstructorString(className)
+                    + handle.getTempData(TempDataStoreTypes.CONSTRUCTOR, className, path)
+                    + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET);
+
+            methods.add(MethodsGenerator.getHashCodeMethodClose(MethodsGenerator.getHashCodeMethodOpen()
+                    + handle.getTempData(TempDataStoreTypes.HASH_CODE, className, path).replace(UtilConstants.NEW_LINE,
+                            "")));
+
+            methods.add(MethodsGenerator
+                    .getEqualsMethodClose(MethodsGenerator.getEqualsMethodOpen(className + UtilConstants.IMPL)
+                            + handle.getTempData(TempDataStoreTypes.EQUALS, className, path)));
+
+            methods.add(MethodsGenerator.getToStringMethodOpen()
+                    + handle.getTempData(TempDataStoreTypes.TO_STRING, className, path)
+                    + MethodsGenerator.getToStringMethodClose());
+
         } catch (ClassNotFoundException | IOException e) {
             log.info("There is no attribute info of " + className + " YANG file in the temporary files.");
             throw new IOException("Fail to read data from temp file.");
         }
 
         /**
-         * Add default constructor and constructor methods.
-         */
-        methods.add(UtilConstants.JAVA_DOC_FIRST_LINE
-                + MethodsGenerator.getDefaultConstructorString(IMPL_CLASS_MASK, className));
-        methods.add(MethodsGenerator.getConstructorString(className));
-
-        /**
          * Add methods in impl class.
          */
         for (String method : methods) {
@@ -249,6 +269,58 @@
     }
 
     /**
+     * Generate class file for type def.
+     *
+     * @param file generated file
+     * @param className file name
+     * @param imports imports for file
+     * @param pkg package path
+     * @param cachedAttributeList attribute list
+     * @param handle  cached file handle
+     * @return type def class file
+     * @throws IOException when fails to generate class file
+     */
+    public static File generateTypeDefClassFile(File file, String className, List<String> imports,
+            String pkg, List<AttributeInfo> cachedAttributeList, CachedFileHandle handle) throws IOException {
+        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
+        initiateFile(file, className, GENERATE_TYPEDEF_CLASS, imports, pkg);
+
+        List<String> typeDef = new ArrayList<>();
+        try {
+            typeDef.add(handle.getTempData(TempDataStoreTypes.TYPE_DEF, className, path));
+        } catch (ClassNotFoundException | IOException e) {
+            log.info("There is no attribute info of " + className + " YANG file in the temporary files.");
+            throw new IOException("Fail to read data from temp file.");
+        }
+
+        /**
+         * Add attributes to the file.
+         */
+        for (String attribute : typeDef) {
+            insert(file, UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + attribute);
+        }
+
+        return file;
+    }
+
+    /**
+     * Returns constructor string for impl class.
+     *
+     * @param yangName class name
+     * @return constructor string
+     */
+    private static String getConstructorString(String yangName) {
+
+        String builderAttribute = yangName.substring(0, 1).toLowerCase() + yangName.substring(1);
+        String javadoc = MethodsGenerator.getConstructorString(yangName);
+        String constructor = UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
+                + yangName + UtilConstants.IMPL + UtilConstants.OPEN_PARENTHESIS + yangName + UtilConstants.BUILDER
+                + UtilConstants.SPACE + builderAttribute + UtilConstants.OBJECT + UtilConstants.CLOSE_PARENTHESIS
+                + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE;
+        return javadoc + constructor;
+    }
+
+    /**
      * Initiate generation of file based on generated file type.
      *
      * @param file generated file
@@ -288,7 +360,6 @@
      *
      * @param file file in which method needs to be appended
      * @param method method which needs to be appended
-     * @exception IOException file operation exceptions
      */
     private static void appendMethod(File file, String method) throws IOException {
         insert(file, method);
@@ -309,17 +380,30 @@
      * Parses attribute info and fetch specific data and creates serialized
      * files of it.
      *
-     * @param attr attribute info
+     * @param attr attribute info.
      * @param genFileType generated file type
      * @param className class name
+     * @param path file path
+     * @param handle cached file handle
      */
-    public static void parseAttributeInfo(AttributeInfo attr, int genFileType, String className) {
+    public static void parseAttributeInfo(AttributeInfo attr, int genFileType, String className, String path,
+            CachedFileHandle handle) {
 
         String attrString = "";
-        String builderInterfaceMethodString = "";
-        String builderClassMethodString = "";
-        String implClassMethodString = "";
+
         String getterString = "";
+        String getterImplString = "";
+
+        String setterString = "";
+        String setterImplString = "";
+
+        String constructorString = "";
+        String typeDefString = "";
+
+        String toString = "";
+        String hashCodeString = "";
+        String equalsString = "";
+
         className = JavaIdentifierSyntax.getCaptialCase(className);
 
         try {
@@ -327,33 +411,124 @@
              * Get the attribute definition and save attributes to temporary
              * file.
              */
-            attrString = JavaCodeSnippetGen.getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(),
-                    attr.getImportInfo().getClassInfo(),
-                    attr.getAttributeName());
-            TempDataStore.setTempData(attrString, TempDataStore.TempDataStoreType.ATTRIBUTE, className);
+
+            boolean isList = attr.isListAttr();
+            String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+            if (attr.isQualifiedName()) {
+                attrString = JavaCodeSnippetGen.getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(),
+                        attr.getImportInfo().getClassInfo(),
+                        attributeName, attr.isListAttr());
+            } else {
+                attrString = JavaCodeSnippetGen.getJavaAttributeDefination(null, attr.getImportInfo().getClassInfo(),
+                        attributeName, attr.isListAttr());
+            }
+            handle.setTempData(attrString + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION,
+                    TempDataStoreTypes.ATTRIBUTE, className,
+                    path);
 
             if ((genFileType & INTERFACE_MASK) != 0) {
                 getterString = MethodsGenerator.getGetterString(attr);
-                TempDataStore.setTempData(getterString, TempDataStore.TempDataStoreType.GETTER_METHODS, className);
+                handle.setTempData(getterString + UtilConstants.NEW_LINE,
+                        TempDataStoreTypes.GETTER_METHODS,
+                        className,
+                        path);
+
             }
 
             if ((genFileType & BUILDER_INTERFACE_MASK) != 0) {
-                builderInterfaceMethodString = MethodsGenerator.parseBuilderInterfaceMethodString(attr, className);
-                TempDataStore.setTempData(builderInterfaceMethodString,
-                        TempDataStore.TempDataStoreType.BUILDER_INTERFACE_METHODS,
-                        className + UtilConstants.BUILDER + UtilConstants.INTERFACE);
+                setterString = MethodsGenerator.getSetterString(attr, className);
+                handle.setTempData(setterString + UtilConstants.NEW_LINE,
+                        TempDataStoreTypes.SETTER_METHODS,
+                        className,
+                        path);
             }
 
             if ((genFileType & BUILDER_CLASS_MASK) != 0) {
-                builderClassMethodString = MethodsGenerator.parseBuilderMethodString(attr, className);
-                TempDataStore.setTempData(builderClassMethodString, TempDataStore.TempDataStoreType.BUILDER_METHODS,
-                        className + UtilConstants.BUILDER);
+                getterImplString = MethodsGenerator.getGetterForClass(attr);
+                handle.setTempData(
+                        MethodsGenerator.getOverRideString() + getterImplString + UtilConstants.NEW_LINE,
+                        TempDataStoreTypes.GETTER_METHODS_IMPL, className,
+                        path);
+                setterImplString = MethodsGenerator.getSetterForClass(attr, className);
+                handle.setTempData(
+                        MethodsGenerator.getOverRideString() + setterImplString + UtilConstants.NEW_LINE,
+                        TempDataStoreTypes.SETTER_METHODS_IMPL, className,
+                        path);
             }
 
             if ((genFileType & IMPL_CLASS_MASK) != 0) {
-                implClassMethodString = MethodsGenerator.parseImplMethodString(attr);
-                TempDataStore.setTempData(implClassMethodString, TempDataStore.TempDataStoreType.IMPL_METHODS,
-                        className + UtilConstants.IMPL);
+                constructorString = MethodsGenerator.getConstructor(className, attr);
+                handle.setTempData(constructorString, TempDataStoreTypes.CONSTRUCTOR, className,
+                        path);
+
+                hashCodeString = MethodsGenerator.getHashCodeMethod(attr);
+                handle.setTempData(hashCodeString + UtilConstants.NEW_LINE,
+                        TempDataStoreTypes.HASH_CODE,
+                        className,
+                        path);
+                equalsString = MethodsGenerator.getEqualsMethod(attr);
+                handle.setTempData(equalsString + UtilConstants.NEW_LINE,
+                        TempDataStoreTypes.EQUALS,
+                        className,
+                        path);
+
+                toString = MethodsGenerator.getToStringMethod(attr);
+                handle.setTempData(toString + UtilConstants.NEW_LINE,
+                        TempDataStoreTypes.TO_STRING,
+                        className,
+                        path);
+
+            }
+
+            if ((genFileType & GENERATE_TYPEDEF_CLASS) != 0) {
+
+                if (attr.isQualifiedName()) {
+                    typeDefString = JavaCodeSnippetGen.getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(),
+                            attr.getImportInfo().getClassInfo(),
+                            attributeName, attr.isListAttr()) + UtilConstants.NEW_LINE;
+                } else {
+                    typeDefString = JavaCodeSnippetGen.getJavaAttributeDefination(null,
+                            attr.getImportInfo().getClassInfo(),
+                            attributeName, attr.isListAttr()) + UtilConstants.NEW_LINE;
+                }
+
+                typeDefString = typeDefString + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                        + UtilConstants.JAVA_DOC_FIRST_LINE;
+
+                typeDefString = typeDefString
+                        + MethodsGenerator.getDefaultConstructorString(className, UtilConstants.PRIVATE)
+                        + UtilConstants.NEW_LINE;
+
+                typeDefString = typeDefString
+                        + JavaDocGen.getJavaDoc(JavaDocType.TYPE_DEF_CONSTRUCTOR, className, isList)
+                        + MethodsGenerator.getTypeDefConstructor(attr, className)
+                        + UtilConstants.NEW_LINE;
+
+                typeDefString = typeDefString + JavaDocGen.getJavaDoc(JavaDocType.OF, className, isList)
+                        + MethodsGenerator.getOfMethod(className, attr) + UtilConstants.NEW_LINE;
+
+                typeDefString = typeDefString + JavaDocGen.getJavaDoc(JavaDocType.GETTER, className, isList)
+                        + MethodsGenerator.getGetterForClass(attr) + UtilConstants.NEW_LINE;
+
+                typeDefString = typeDefString + JavaDocGen.getJavaDoc(JavaDocType.TYPE_DEF_SETTER, className, isList)
+                        + MethodsGenerator.getSetterForTypeDefClass(attr)
+                        + UtilConstants.NEW_LINE;
+
+                hashCodeString = hashCodeString + MethodsGenerator.getHashCodeMethodOpen()
+                        + MethodsGenerator.getHashCodeMethod(attr).replace(UtilConstants.NEW_LINE, "");
+                hashCodeString = MethodsGenerator.getHashCodeMethodClose(hashCodeString) + UtilConstants.NEW_LINE;
+
+                equalsString = equalsString + MethodsGenerator.getEqualsMethodOpen(className) + UtilConstants.NEW_LINE
+                        + MethodsGenerator.getEqualsMethod(attr);
+                equalsString = MethodsGenerator.getEqualsMethodClose(equalsString) + UtilConstants.NEW_LINE;
+
+                toString = toString + MethodsGenerator.getToStringMethodOpen()
+                        + MethodsGenerator.getToStringMethod(attr) + UtilConstants.NEW_LINE
+                        + MethodsGenerator.getToStringMethodClose()
+                        + UtilConstants.NEW_LINE;
+                typeDefString = typeDefString + hashCodeString + equalsString + toString;
+                handle.setTempData(typeDefString, TempDataStoreTypes.TYPE_DEF, className,
+                        path);
             }
         } catch (IOException e) {
             log.info("Failed to set data for " + attr.getAttributeName() + " in temp data files.");
@@ -368,18 +543,34 @@
      * @param fileName generated file name
      * @param type generated file type
      * @param pkg generated file package
-     * @param importsList list of java imports
+     * @param importsList list of java imports.
      * @throws IOException when fails to append contents
      */
     private static void appendContents(File file, String fileName, int type, List<String> importsList,
             String pkg) throws IOException {
 
+        if (pkg.contains(UtilConstants.YANG_GEN_DIR)) {
+            String[] strArray = pkg.split(UtilConstants.YANG_GEN_DIR);
+            pkg = strArray[1].replace(UtilConstants.SLASH, UtilConstants.PERIOD);
+        }
+
         if ((type & IMPL_CLASS_MASK) != 0) {
 
             write(file, fileName, type, JavaDocType.IMPL_CLASS);
         } else if ((type & BUILDER_INTERFACE_MASK) != 0) {
 
             write(file, fileName, type, JavaDocType.BUILDER_INTERFACE);
+        } else if ((type & GENERATE_TYPEDEF_CLASS) != 0) {
+            insert(file, CopyrightHeader.getCopyrightHeader());
+            insert(file, "package" + UtilConstants.SPACE + pkg + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE);
+            if (importsList != null) {
+                insert(file, UtilConstants.NEW_LINE);
+                for (String imports : importsList) {
+                    insert(file, imports);
+                }
+                insert(file, UtilConstants.NEW_LINE);
+            }
+            write(file, fileName, type, JavaDocType.IMPL_CLASS);
         } else {
 
             if ((type & INTERFACE_MASK) != 0) {
@@ -420,7 +611,7 @@
     private static void write(File file, String fileName, int genType, JavaDocGen.JavaDocType javaDocType)
             throws IOException {
 
-        insert(file, JavaDocGen.getJavaDoc(javaDocType, fileName));
+        insert(file, JavaDocGen.getJavaDoc(javaDocType, fileName, false));
         insert(file, JavaCodeSnippetGen.getJavaClassDefStart(genType, fileName));
     }
 
@@ -433,13 +624,27 @@
      */
     public static void insert(File file, String data) throws IOException {
         try {
-            FileSystemUtil.insertStringInFile(file, data);
+            FileSystemUtil.updateFileHandle(file, data, false);
         } catch (IOException e) {
             throw new IOException("Failed to insert in " + file + "file");
         }
     }
 
     /**
+     * Closes the files handle for generate files.
+     *
+     * @param file generate files
+     * @throws IOException when failed to close the file handle
+     */
+    public static void closeFileHandles(File file) throws IOException {
+        try {
+            FileSystemUtil.updateFileHandle(file, null, true);
+        } catch (IOException e) {
+            throw new IOException("Failed to close file handle for " + file + "file");
+        }
+    }
+
+    /**
      * Removes temp files.
      *
      * @param file file to be removed
@@ -449,4 +654,14 @@
             file.delete();
         }
     }
+
+    /**
+     * Removes temp files.
+     *
+     * @param tempDir temp directory
+     * @throws IOException when fails to delete the directory
+     */
+    public static void cleanTempFiles(File tempDir) throws IOException {
+        FileUtils.deleteDirectory(tempDir);
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index dd543ca..2f79931 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -31,7 +31,6 @@
     private static final int INDEX_ZERO = 0;
     private static final int INDEX_ONE = 1;
     private static final int INDEX_TWO = 2;
-    private static final int INDEX_THREE = 3;
 
     /**
      * Default constructor.
@@ -100,9 +99,7 @@
         String[] revisionArr = date.split(UtilConstants.HYPHEN);
 
         String rev = "rev";
-        String year = revisionArr[INDEX_ZERO];
-        char[] yearBytes = year.toCharArray();
-        rev = rev + yearBytes[INDEX_TWO] + yearBytes[INDEX_THREE];
+        rev = rev + revisionArr[INDEX_ZERO];
 
         if ((Integer.parseInt(revisionArr[INDEX_ONE]) <= MAX_MONTHS)
                 && Integer.parseInt(revisionArr[INDEX_TWO]) <= MAX_DAYS) {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index e2e6211..6ca6829 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -19,6 +19,7 @@
 import org.onosproject.yangutils.translator.tojava.AttributeInfo;
 import org.onosproject.yangutils.utils.UtilConstants;
 import org.onosproject.yangutils.utils.io.impl.JavaDocGen;
+import org.onosproject.yangutils.utils.io.impl.YangIoUtils;
 
 /**
  * Generated methods for generated files based on the file type.
@@ -32,45 +33,6 @@
     }
 
     /**
-     * Returns the methods strings for builder class.
-     *
-     * @param attr attribute info
-     * @param className java class name
-     * @return method string for builder class
-     */
-    static String parseBuilderMethodString(AttributeInfo attr, String className) {
-        String attrQuaifiedType = "";
-        if (attr.getImportInfo().getPkgInfo() != null) {
-            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
-
-        String overrideString = UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
-                + UtilConstants.OVERRIDE + UtilConstants.NEW_LINE;
-        String getterString = getGetterForClass(attr.getAttributeName(), attrQuaifiedType);
-        String setterString = getSetterForClass(attr.getAttributeName(), attrQuaifiedType, className);
-        return overrideString + getterString + UtilConstants.NEW_LINE + overrideString + setterString;
-    }
-
-    /**
-     * Returns the methods strings for builder class.
-     *
-     * @param attr attribute info
-     * @return method string for builder class
-     */
-    static String parseImplMethodString(AttributeInfo attr) {
-
-        String attrQuaifiedType = "";
-        if (attr.getImportInfo().getPkgInfo() != null) {
-            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
-
-        return UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.OVERRIDE
-                + UtilConstants.NEW_LINE + getGetterForClass(attr.getAttributeName(), attrQuaifiedType);
-    }
-
-    /**
      * Returns the methods strings for builder interface.
      *
      * @param attr attribute info
@@ -90,7 +52,7 @@
      */
     public static String parseBuilderInterfaceBuildMethodString(String name) {
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.BUILD, name)
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.BUILD, name, false)
                 + getBuildForInterface(name);
     }
 
@@ -103,14 +65,17 @@
     public static String getGetterString(AttributeInfo attr) {
 
         String returnType = "";
-        if (attr.getImportInfo().getPkgInfo() != null) {
+        boolean isList = attr.isListAttr();
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
             returnType = attr.getImportInfo().getPkgInfo() + ".";
         }
 
         returnType = returnType + attr.getImportInfo().getClassInfo();
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.GETTER, attr.getAttributeName())
-                + getGetterForInterface(attr.getAttributeName(), returnType)
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.GETTER, attributeName, isList) +
+
+                getGetterForInterface(attributeName, returnType, attr.isListAttr())
                 + UtilConstants.NEW_LINE;
     }
 
@@ -121,17 +86,20 @@
      * @param className java class name
      * @return setter string
      */
-    private static String getSetterString(AttributeInfo attr, String className) {
+    public static String getSetterString(AttributeInfo attr, String className) {
 
         String attrType = "";
-        if (attr.getImportInfo().getPkgInfo() != null) {
+        boolean isList = attr.isListAttr();
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
             attrType = attr.getImportInfo().getPkgInfo() + ".";
         }
 
         attrType = attrType + attr.getImportInfo().getClassInfo();
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.SETTER, attr.getAttributeName())
-                + getSetterForInterface(attr.getAttributeName(), attrType, className);
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.SETTER, attributeName, isList)
+                + getSetterForInterface(attributeName, attrType, className, attr.isListAttr())
+                + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -142,21 +110,75 @@
      */
     public static String getConstructorString(String name) {
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.CONSTRUCTOR, name)
-                + getConstructor(name);
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.CONSTRUCTOR, name, false);
     }
 
     /**
      * Returns default constructor method string.
      *
-     * @param type generated file type
      * @param name class name
+     * @param modifierType modifier type
      * @return default constructor string
      */
-    public static String getDefaultConstructorString(int type, String name) {
+    public static String getDefaultConstructorString(String name, String modifierType) {
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR, name)
-                + getDefaultConstructor(name + UtilConstants.BUILDER);
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR, name, false)
+                + getDefaultConstructor(name, modifierType);
+    }
+
+    /**
+     * Returns default constructor method string.
+     *
+     * @param attr attribute info
+     * @param className class name
+     * @return default constructor string
+     */
+    public static String getTypeDefConstructor(AttributeInfo attr, String className) {
+
+        String attrQuaifiedType = "";
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
+            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
+        }
+        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+
+        if (!attr.isListAttr()) {
+            return getTypeDefConstructorString(attrQuaifiedType, attributeName, className);
+        }
+        String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET;
+        return getTypeDefConstructorString(listAttr, attributeName, className);
+    }
+
+    /**
+     * Returns type def's constructor for attribute.
+     *
+     * @param type data type
+     * @param name attribute name
+     * @param className class name
+     * @return setter for type def's attribute
+     */
+    private static String getTypeDefConstructorString(String type, String name, String className) {
+
+        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
+                + className + UtilConstants.OPEN_PARENTHESIS
+                + type + UtilConstants.SPACE + "value" + UtilConstants.CLOSE_PARENTHESIS
+                + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE
+                + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS
+                + UtilConstants.PERIOD + name + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE
+                + "value" + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                + UtilConstants.CLOSE_CURLY_BRACKET;
+    }
+
+    /**
+     * Returns check not null string.
+     *
+     * @param name attribute name
+     * @return check not null string
+     */
+    public static String getCheckNotNull(String name) {
+        return UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.CHECK_NOT_NULL_STRING
+                + UtilConstants.OPEN_PARENTHESIS + name + UtilConstants.COMMA + UtilConstants.SPACE + name
+                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -174,56 +196,171 @@
     /**
      * Returns the getter method strings for class file.
      *
-     * @param attrName name of the attribute
-     * @param attrType return type of attribute
+     * @param attr attribute info
      * @return getter method for class
      */
-    private static String getGetterForClass(String attrName, String attrType) {
+    public static String getGetterForClass(AttributeInfo attr) {
+
+        String attrQuaifiedType = "";
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
+            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
+        }
+        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+
+        if (!attr.isListAttr()) {
+            return getGetter(attrQuaifiedType, attributeName);
+        }
+        String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET;
+        return getGetter(listAttr, attributeName);
+    }
+
+    /**
+     * Returns getter for attribute.
+     *
+     * @param type return type
+     * @param name attribute name
+     * @return getter for attribute
+     */
+    private static String getGetter(String type, String name) {
 
         return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
-                + attrType + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX
-                + JavaIdentifierSyntax.getCaptialCase(attrName) + UtilConstants.OPEN_PARENTHESIS
+                + type + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX
+                + JavaIdentifierSyntax.getCaptialCase(name) + UtilConstants.OPEN_PARENTHESIS
                 + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
                 + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN
-                + UtilConstants.SPACE + attrName + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+                + UtilConstants.SPACE + name + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
                 + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
     }
 
     /**
      * Returns the setter method strings for class file.
      *
-     * @param attrName name of the attribute
-     * @param attrType return type of attribute
+     * @param attr attribute info
      * @param className name of the class
      * @return setter method for class
      */
-    private static String getSetterForClass(String attrName, String attrType, String className) {
+    public static String getSetterForClass(AttributeInfo attr, String className) {
+
+        String attrQuaifiedType = "";
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
+            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
+        }
+        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        if (!attr.isListAttr()) {
+            return getSetter(className, attributeName, attrQuaifiedType);
+        }
+        String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET;
+        return getSetter(className, attributeName, listAttr);
+    }
+
+    /**
+     * Returns setter for attribute.
+     *
+     * @param className class name
+     * @param name attribute name
+     * @param type return type
+     * @return setter for attribute
+     */
+    private static String getSetter(String className, String name, String type) {
 
         return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
                 + className + UtilConstants.BUILDER + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX
-                + JavaIdentifierSyntax.getCaptialCase(attrName) + UtilConstants.OPEN_PARENTHESIS
-                + attrType + UtilConstants.SPACE + attrName + UtilConstants.CLOSE_PARENTHESIS
+                + JavaIdentifierSyntax.getCaptialCase(name) + UtilConstants.OPEN_PARENTHESIS
+                + type + UtilConstants.SPACE + name + UtilConstants.CLOSE_PARENTHESIS
                 + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE
                 + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS + UtilConstants.PERIOD
-                + attrName + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE + attrName
-                + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION
+                + name + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE
+                + name + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION
                 + UtilConstants.RETURN + UtilConstants.SPACE + UtilConstants.THIS + UtilConstants.SEMI_COLAN
                 + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
     }
 
     /**
+     * Returns the setter method strings for class file.
+     *
+     * @param attr attribute info
+     * @return setter method for class
+     */
+    public static String getSetterForTypeDefClass(AttributeInfo attr) {
+
+        String attrQuaifiedType = "";
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
+            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
+        }
+        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+
+        if (!attr.isListAttr()) {
+            return getTypeDefSetter(attrQuaifiedType, attributeName);
+        }
+        String listAttr = getListString() + attrQuaifiedType + UtilConstants.DIAMOND_CLOSE_BRACKET;
+        return getTypeDefSetter(listAttr, attributeName);
+    }
+
+    /**
+     * Returns type def's setter for attribute.
+     *
+     * @param type data type
+     * @param name attribute name
+     * @return setter for type def's attribute
+     */
+    private static String getTypeDefSetter(String type, String name) {
+
+        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
+                + UtilConstants.VOID + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX
+                + JavaIdentifierSyntax.getCaptialCase(name) + UtilConstants.OPEN_PARENTHESIS
+                + type + UtilConstants.SPACE + "value" + UtilConstants.CLOSE_PARENTHESIS
+                + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE
+                + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS + UtilConstants.PERIOD
+                + name + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE
+                + "value" + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                + UtilConstants.CLOSE_CURLY_BRACKET;
+    }
+
+    /**
+     * Returns override string.
+     *
+     * @return override string
+     */
+    public static String getOverRideString() {
+        return UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                + UtilConstants.OVERRIDE + UtilConstants.NEW_LINE;
+    }
+
+    /**
      * Returns the getter method strings for interface file.
      *
      * @param yangName name of the attribute
      * @param returnType return type of attribute
+     * @param isList is list attribute
      * @return getter method for interface
      */
-    private static String getGetterForInterface(String yangName, String returnType) {
+    public static String getGetterForInterface(String yangName, String returnType, boolean isList) {
+
+        if (!isList) {
+            return getGetterInterfaceString(returnType, yangName);
+        }
+        String listAttr = getListString() + returnType + UtilConstants.DIAMOND_CLOSE_BRACKET;
+        return getGetterInterfaceString(listAttr, yangName);
+    }
+
+    /**
+     * Returns getter for attribute in interface.
+     *
+     * @param returnType return type
+     * @param yangName attribute name
+     * @return getter for interface
+     */
+    private static String getGetterInterfaceString(String returnType, String yangName) {
+
         return UtilConstants.FOUR_SPACE_INDENTATION + returnType
                 + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX
                 + JavaIdentifierSyntax.getCaptialCase(yangName)
                 + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS
                 + UtilConstants.SEMI_COLAN;
+
     }
 
     /**
@@ -232,9 +369,28 @@
      * @param attrName name of the attribute
      * @param attrType return type of attribute
      * @param className name of the java class being generated
+     * @param isList is list attribute
      * @return setter method for interface
      */
-    private static String getSetterForInterface(String attrName, String attrType, String className) {
+    public static String getSetterForInterface(String attrName, String attrType, String className, boolean isList) {
+
+        if (!isList) {
+            return getSetterInterfaceString(className, attrName, attrType);
+        }
+        String listAttr = getListString() + attrType + UtilConstants.DIAMOND_CLOSE_BRACKET;
+        return getSetterInterfaceString(className, attrName, listAttr);
+    }
+
+    /**
+     * Returns setter string for interface.
+     *
+     * @param className class name
+     * @param attrName attribute name
+     * @param attrType attribute type
+     * @return setter string
+     */
+    private static String getSetterInterfaceString(String className, String attrName, String attrType) {
+
         return UtilConstants.FOUR_SPACE_INDENTATION + className + UtilConstants.BUILDER
                 + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX
                 + JavaIdentifierSyntax.getCaptialCase(attrName) + UtilConstants.OPEN_PARENTHESIS
@@ -243,48 +399,47 @@
     }
 
     /**
+     * Returns list string.
+     *
+     * @return list string
+     */
+    private static String getListString() {
+        return UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET;
+    }
+
+    /**
      * Returns the build method strings for interface file.
      *
      * @param yangName name of the interface
      * @return build method for interface
      */
-    private static String getBuildForInterface(String yangName) {
+    public static String getBuildForInterface(String yangName) {
 
         return UtilConstants.FOUR_SPACE_INDENTATION + yangName + UtilConstants.SPACE + UtilConstants.BUILD
-                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN;
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN
+                + UtilConstants.NEW_LINE;
     }
 
     /**
      * Returns the constructor strings for class file.
      *
      * @param yangName name of the class
+     * @param attr attribute info
      * @return constructor for class
      */
-    private static String getConstructor(String yangName) {
+    public static String getConstructor(String yangName, AttributeInfo attr) {
 
-        String builderAttribute = yangName.substring(0, 1).toLowerCase() + yangName.substring(1);
-        String constructor = UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
-                + yangName + UtilConstants.IMPL + UtilConstants.OPEN_PARENTHESIS + yangName + UtilConstants.BUILDER
-                + UtilConstants.SPACE + builderAttribute + UtilConstants.OBJECT + UtilConstants.CLOSE_PARENTHESIS
-                + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE;
+        String builderAttribute = JavaIdentifierSyntax.getLowerCase(yangName);
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        String constructor = UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS
+                + UtilConstants.PERIOD + JavaIdentifierSyntax.getCamelCase(attributeName)
+                + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE + builderAttribute
+                + UtilConstants.OBJECT + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX
+                + JavaIdentifierSyntax.getCaptialCase(JavaIdentifierSyntax.getCamelCase(attributeName))
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN
+                + UtilConstants.NEW_LINE;
 
-        //        TODO: need to get the partial constructor from constructor temp file.
-        //        if (getAttrInfo() != null) {
-        //            for (AttributeInfo attribute : getAttrInfo()) {
-        //                attribute.setAttributeName(JavaIdentifierSyntax.getCamelCase(attribute.getAttributeName()));
-        //                constructor = constructor + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.THIS
-        //                        + UtilConstants.PERIOD + attribute.getAttributeName() + UtilConstants.SPACE
-        //                        + UtilConstants.EQUAL + UtilConstants.SPACE + builderAttribute + UtilConstants.OBJECT
-        //                        + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX
-        //                        + JavaIdentifierSyntax.getCaptialCase(attribute.getAttributeName())
-        //                        + UtilConstants.OPEN_PARENTHESIS
-        //        + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN
-        //                        + UtilConstants.NEW_LINE;
-        //            }
-        //            getAttrInfo().clear();
-        //        }
-
-        return constructor + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
+        return constructor;
     }
 
     /**
@@ -293,10 +448,10 @@
      * @param yangName class name
      * @return build method string for class
      */
-    private static String getBuild(String yangName) {
+    public static String getBuild(String yangName) {
 
-        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + yangName
-                + UtilConstants.SPACE + UtilConstants.BUILD + UtilConstants.OPEN_PARENTHESIS
+        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
+                + yangName + UtilConstants.SPACE + UtilConstants.BUILD + UtilConstants.OPEN_PARENTHESIS
                 + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
                 + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN
                 + UtilConstants.SPACE + UtilConstants.NEW + UtilConstants.SPACE + yangName + UtilConstants.IMPL
@@ -309,14 +464,205 @@
      * Returns the Default constructor strings for class file.
      *
      * @param name name of the class
+     * @param modifierType modifier type for default constructor
      * @return Default constructor for class
      */
-    private static String getDefaultConstructor(String name) {
+    private static String getDefaultConstructor(String name, String modifierType) {
 
-        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + name
+        return UtilConstants.FOUR_SPACE_INDENTATION + modifierType + UtilConstants.SPACE + name
                 + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE
                 + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
                 + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE;
     }
 
+    /**
+     * Returns to string method open strings.
+     *
+     * @return to string method open string
+     */
+    public static String getToStringMethodOpen() {
+
+        return getOverRideString() + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
+                + UtilConstants.STRING + UtilConstants.SPACE + "to" + UtilConstants.STRING
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE
+                + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION
+                + UtilConstants.RETURN + " MoreObjects.toStringHelper(getClass())" + UtilConstants.NEW_LINE;
+    }
+
+    /**
+     * Returns to string methods close string.
+     *
+     * @return to string method close string
+     */
+    public static String getToStringMethodClose() {
+        return UtilConstants.TWELVE_SPACE_INDENTATION + ".to" + UtilConstants.STRING
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN
+                + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                + UtilConstants.CLOSE_CURLY_BRACKET;
+    }
+
+    /**
+     * To string method for class.
+     *
+     * @param attr attribute info
+     * @return to string method
+     */
+    public static String getToStringMethod(AttributeInfo attr) {
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        return UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.PERIOD + UtilConstants.ADD_STRING
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.QUOTES
+                + attributeName + UtilConstants.QUOTES + UtilConstants.COMMA + UtilConstants.SPACE + attributeName
+                + UtilConstants.CLOSE_PARENTHESIS;
+
+    }
+
+    /**
+     * Returns to hash code method open strings.
+     *
+     * @return to hash code method open string
+     */
+    public static String getHashCodeMethodOpen() {
+
+        return getOverRideString() + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
+                + UtilConstants.INT + UtilConstants.SPACE + UtilConstants.HASH_CODE_STRING
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE
+                + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION
+                + UtilConstants.RETURN + " Objects.hash" + UtilConstants.OPEN_PARENTHESIS;
+    }
+
+    /**
+     * Returns to hash code methods close string.
+     *
+     * @param hashcodeString hash code string
+     * @return to hash code method close string
+     */
+    public static String getHashCodeMethodClose(String hashcodeString) {
+        hashcodeString = YangIoUtils.trimAtLast(hashcodeString, UtilConstants.COMMA);
+        hashcodeString = YangIoUtils.trimAtLast(hashcodeString, UtilConstants.SPACE);
+        hashcodeString = YangIoUtils.partString(hashcodeString);
+        return hashcodeString + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
+    }
+
+    /**
+     * Hash code method for class.
+     *
+     * @param attr attribute info
+     * @return hash code method
+     */
+    public static String getHashCodeMethod(AttributeInfo attr) {
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        return attributeName
+                + UtilConstants.COMMA + UtilConstants.SPACE;
+
+    }
+
+    /**
+     * Returns to equals method open strings.
+     *
+     * @param className class name
+     * @return to equals method open string
+     */
+    public static String getEqualsMethodOpen(String className) {
+
+        return getOverRideString() + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
+                + UtilConstants.BOOLEAN + UtilConstants.SPACE + UtilConstants.EQUALS_STRING
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.OBJECT_STRING + UtilConstants.SPACE + "obj"
+                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
+                + UtilConstants.NEW_LINE + getEqualsMethodsCommonIfCondition()
+                + getEqualsMethodsSpecificIfCondition(className);
+    }
+
+    /**
+     * Returns equal methods if condition string.
+     *
+     * @return if condition string
+     */
+    private static String getEqualsMethodsCommonIfCondition() {
+        return UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.IF + UtilConstants.SPACE
+                + UtilConstants.OPEN_PARENTHESIS + UtilConstants.THIS
+                + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.EQUAL + UtilConstants.SPACE + "obj"
+                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
+                + UtilConstants.NEW_LINE + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.RETURN
+                + UtilConstants.SPACE + UtilConstants.TRUE + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+                + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE;
+    }
+
+    /**
+     * Returns if condition for specific class object in equals method.
+     *
+     * @param className class name
+     * @return if condition string
+     */
+    private static String getEqualsMethodsSpecificIfCondition(String className) {
+        return UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.IF + UtilConstants.SPACE
+                + UtilConstants.OPEN_PARENTHESIS + "obj" + UtilConstants.INSTANCE_OF + className
+                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
+                + UtilConstants.NEW_LINE + UtilConstants.TWELVE_SPACE_INDENTATION + className + UtilConstants.SPACE
+                + "other " + UtilConstants.EQUAL + UtilConstants.SPACE + UtilConstants.OPEN_PARENTHESIS + className
+                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + "obj" + UtilConstants.SEMI_COLAN
+                + UtilConstants.NEW_LINE + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.RETURN
+                + UtilConstants.NEW_LINE;
+    }
+
+    /**
+     * Returns to equals methods close string.
+     *
+     * @param equalMethodString equal method string
+     * @return to equals method close string
+     */
+    public static String getEqualsMethodClose(String equalMethodString) {
+        equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.AND);
+        equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.AND);
+        equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.SPACE);
+        equalMethodString = YangIoUtils.trimAtLast(equalMethodString, UtilConstants.NEW_LINE) + UtilConstants.SEMI_COLAN
+                + UtilConstants.NEW_LINE;
+        return equalMethodString + UtilConstants.EIGHT_SPACE_INDENTATION
+                + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE
+                + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.SPACE
+                + UtilConstants.FALSE + UtilConstants.SEMI_COLAN
+                + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                + UtilConstants.CLOSE_CURLY_BRACKET;
+    }
+
+    /**
+     * Equals method for class.
+     *
+     * @param attr attribute info
+     * @return equals method
+     */
+    public static String getEqualsMethod(AttributeInfo attr) {
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        return UtilConstants.SIXTEEN_SPACE_INDENTATION + UtilConstants.SPACE + UtilConstants.OBJECT_STRING + "s"
+                + UtilConstants.PERIOD + UtilConstants.EQUALS_STRING + UtilConstants.OPEN_PARENTHESIS + attributeName
+                + UtilConstants.COMMA + UtilConstants.SPACE + "other." + attributeName + UtilConstants.CLOSE_PARENTHESIS
+                + UtilConstants.SPACE + UtilConstants.AND + UtilConstants.AND;
+
+    }
+
+    /**
+     * Returns of method string for class.
+     *
+     * @param name class name
+     * @param attr attribute info
+     * @return of method string
+     */
+    public static String getOfMethod(String name, AttributeInfo attr) {
+
+        String attrQuaifiedType = "";
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
+            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
+        }
+        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+
+        return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + UtilConstants.STATIC
+                + UtilConstants.SPACE + name + UtilConstants.SPACE + UtilConstants.OF + UtilConstants.OPEN_PARENTHESIS
+                + attrQuaifiedType + UtilConstants.SPACE + UtilConstants.VALUE + UtilConstants.CLOSE_PARENTHESIS
+                + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE
+                + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.SPACE + UtilConstants.NEW
+                + UtilConstants.SPACE + name + UtilConstants.OPEN_PARENTHESIS + UtilConstants.VALUE
+                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE;
+    }
+
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/TempDataStoreTypes.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/TempDataStoreTypes.java
new file mode 100644
index 0000000..0344672
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/TempDataStoreTypes.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.translator.tojava.utils;
+
+/**
+ * Data Store types.
+ */
+public enum TempDataStoreTypes {
+
+    /**
+     * Getter methods for interfaces.
+     */
+    GETTER_METHODS,
+
+    /**
+     * Getter methods impl for classes.
+     */
+    GETTER_METHODS_IMPL,
+
+    /**
+     * Setter methods for interfaces.
+     */
+    SETTER_METHODS,
+
+    /**
+     * Setter methods impl for classes.
+     */
+    SETTER_METHODS_IMPL,
+
+    /**
+     * Constructor for impl class.
+     */
+    CONSTRUCTOR,
+
+    /**
+     * Attributes.
+     */
+    ATTRIBUTE,
+
+    /**
+     * TypeDef.
+     */
+    TYPE_DEF,
+
+    /**
+     * ToString method.
+     */
+    TO_STRING,
+
+    /**
+     * HashCode method.
+     */
+    HASH_CODE,
+
+    /**
+     * Equals method.
+     */
+    EQUALS
+}