YANG Translator optimization

Change-Id: Ie6a6b9d371a4fc5fd973cf56d6f3c7b44a3146ba
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/AttributeInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/AttributeInfo.java
deleted file mode 100644
index 794fb4c..0000000
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/AttributeInfo.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * 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;
-
-import org.onosproject.yangutils.datamodel.YangType;
-
-/**
- * Maintains the attribute info corresponding to class/interface generated.
- */
-public class AttributeInfo {
-
-    /**
-     * The data type info of attribute.
-     */
-    private YangType<?> attrType;
-
-    /**
-     * Name of the attribute.
-     */
-    private String name;
-
-    /**
-     * If the added attribute is a list of info.
-     */
-    private boolean isListAttr = false;
-
-    /**
-     * If the added attribute has to be accessed in a fully qualified manner.
-     */
-    private boolean isQualifiedName = false;
-
-    /**
-     * The class info will be used to set the attribute type and package info
-     * will be use for qualified name.
-     */
-    private ImportInfo importInfo;
-
-    /**
-     * Default constructor.
-     */
-    public AttributeInfo() {
-    }
-
-    /**
-     * Get the data type info of attribute.
-     *
-     * @return the data type info of attribute
-     */
-    public YangType<?> getAttributeType() {
-        return attrType;
-    }
-
-    /**
-     * Set the data type info of attribute.
-     *
-     * @param type the data type info of attribute
-     */
-    public void setAttributeType(YangType<?> type) {
-
-        attrType = type;
-    }
-
-    /**
-     * Get name of the attribute.
-     *
-     * @return name of the attribute
-     */
-    public String getAttributeName() {
-        return name;
-    }
-
-    /**
-     * Set name of the attribute.
-     *
-     * @param attrName name of the attribute
-     */
-    public void setAttributeName(String attrName) {
-        name = attrName;
-    }
-
-    /**
-     * Get if the added attribute is a list of info.
-     *
-     * @return the if the added attribute is a list of info
-     */
-    public boolean isListAttr() {
-        return isListAttr;
-    }
-
-    /**
-     * Set if the added attribute is a list of info.
-     *
-     * @param isList if the added attribute is a list of info
-     */
-    public void setListAttr(boolean isList) {
-        isListAttr = isList;
-    }
-
-    /**
-     * Get if the added attribute has to be accessed in a fully qualified
-     * manner.
-     *
-     * @return the if the added attribute has to be accessed in a fully
-     *         qualified manner.
-     */
-    public boolean isQualifiedName() {
-        return isQualifiedName;
-    }
-
-    /**
-     * Set if the added attribute has to be accessed in a fully qualified
-     * manner.
-     *
-     * @param isQualified if the added attribute has to be accessed in a fully
-     *            qualified manner
-     */
-    public void setQualifiedName(boolean isQualified) {
-        isQualifiedName = isQualified;
-    }
-
-    /**
-     * Get the import info for the attribute type. It will be null, of the type
-     * is basic built-in java type.
-     *
-     * @return import info
-     */
-    public ImportInfo getImportInfo() {
-        return importInfo;
-    }
-
-    /**
-     * Set the import info for the attribute type.
-     *
-     * @param importInfo import info for the attribute type
-     */
-    public void setImportInfo(ImportInfo importInfo) {
-        this.importInfo = importInfo;
-    }
-
-}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/CachedJavaFileHandle.java b/src/main/java/org/onosproject/yangutils/translator/tojava/CachedJavaFileHandle.java
deleted file mode 100644
index 338cba3..0000000
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/CachedJavaFileHandle.java
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- * 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;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.translator.CachedFileHandle;
-import org.onosproject.yangutils.translator.GeneratedFileType;
-import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
-import org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator;
-import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
-import org.onosproject.yangutils.translator.tojava.utils.TempDataStoreTypes;
-import org.onosproject.yangutils.utils.UtilConstants;
-import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
-
-/**
- * Maintain the information about the java file to be generated.
- */
-public class CachedJavaFileHandle implements CachedFileHandle {
-
-    private static final int MAX_CACHABLE_ATTR = 64;
-    private static final String JAVA_FILE_EXTENSION = ".java";
-    private static final String TEMP_FILE_EXTENSION = ".tmp";
-    private static final String GETTER_METHOD_FILE_NAME = "GetterMethod";
-    private static final String SETTER_METHOD_FILE_NAME = "SetterMethod";
-    private static final String GETTER_METHOD_IMPL_FILE_NAME = "GetterMethodImpl";
-    private static final String SETTER_METHOD_IMPL_FILE_NAME = "SetterMethodImpl";
-    private static final String CONSTRUCTOR_FILE_NAME = "Constructor";
-    private static final String ATTRIBUTE_FILE_NAME = "Attributes";
-    private static final String TO_STRING_METHOD_FILE_NAME = "ToString";
-    private static final String HASH_CODE_METHOD_FILE_NAME = "HashCode";
-    private static final String EQUALS_METHOD_FILE_NAME = "Equals";
-    private static final String TYPE_DEF_FILE_NAME = "TypeDef";
-    private static final String TEMP_FOLDER_NAME_SUFIX = "-Temp";
-
-    /**
-     * The type(s) of java source file(s) to be generated when the cached file
-     * handle is closed.
-     */
-    private int genFileTypes;
-
-    /**
-     * Name of the object in YANG file.
-     */
-    private String yangName;
-
-    /**
-     * Sorted set of import info, to be used to maintain the set of classes to
-     * be imported in the generated class.
-     */
-    private SortedSet<ImportInfo> importSet;
-
-    /**
-     * Cached list of attribute info.
-     */
-    private List<AttributeInfo> attributeList;
-
-    /**
-     * File generation directory path.
-     */
-    private String relativeFilePath;
-
-    /**
-     * File generation base directory path.
-     */
-    private String codeGenDirFilePath;
-
-    /**
-     * Prevent invoking default constructor.
-     */
-    public CachedJavaFileHandle() {
-        setCachedAttributeList(new LinkedList<AttributeInfo>());
-    }
-
-    /**
-     * Create a cached file handle which takes care of adding attributes to the
-     * generated java file.
-     *
-     * @param pcg package in which class/interface need to be generated
-     * @param yangName name of the attribute in YANG file
-     * @param types the types of files that needs to be generated
-     * @throws IOException file IO exception
-     */
-    public CachedJavaFileHandle(String pcg, String yangName, int types) throws IOException {
-        setCachedAttributeList(new LinkedList<AttributeInfo>());
-        setImportSet(new TreeSet<ImportInfo>());
-        setRelativeFilePath(pcg.replace(".", "/"));
-        setGeneratedFileTypes(types);
-        setYangName(yangName);
-    }
-
-    /**
-     * Get the types of files being generated corresponding to the YANG
-     * definition.
-     *
-     * @return the types of files being generated corresponding to the YANG
-     *         definition
-     */
-    public int getGeneratedFileTypes() {
-        return genFileTypes;
-    }
-
-    /**
-     * Set the types of files being generated corresponding to the YANG
-     * definition.
-     *
-     * @param fileTypes the types of files being generated corresponding to the
-     *            YANG definition
-     */
-    public void setGeneratedFileTypes(int fileTypes) {
-        genFileTypes = fileTypes;
-    }
-
-    /**
-     * Get the corresponding name defined in YANG.
-     *
-     * @return the corresponding name defined in YANG
-     */
-    public String getYangName() {
-        return yangName;
-    }
-
-    /**
-     * Set the corresponding name defined in YANG.
-     *
-     * @param yangName the corresponding name defined in YANG
-     */
-    public void setYangName(String yangName) {
-        this.yangName = yangName;
-    }
-
-    /**
-     * Get the set containing the imported class/interface info.
-     *
-     * @return the set containing the imported class/interface info
-     */
-    public SortedSet<ImportInfo> getImportSet() {
-        return importSet;
-    }
-
-    /**
-     * Assign the set containing the imported class/interface info.
-     *
-     * @param importSet the set containing the imported class/interface info
-     */
-    private void setImportSet(SortedSet<ImportInfo> importSet) {
-        this.importSet = importSet;
-    }
-
-    /**
-     * Add an imported class/interface info is it is not already part of the
-     * set. If already part of the set, return false, else add to set and return
-     * true.
-     *
-     * @param importInfo class/interface info being imported
-     * @return status of new addition of class/interface to the import set
-     */
-    public boolean addImportInfo(ImportInfo importInfo) {
-        return getImportSet().add(importInfo);
-    }
-
-    /**
-     * Get the list of cached attribute list.
-     *
-     * @return the set containing the imported class/interface info
-     */
-    public List<AttributeInfo> getCachedAttributeList() {
-        return attributeList;
-    }
-
-    /**
-     * Set the cached attribute list.
-     *
-     * @param attrList attribute list
-     */
-    private void setCachedAttributeList(List<AttributeInfo> attrList) {
-        attributeList = attrList;
-    }
-
-    @Override
-    public void setRelativeFilePath(String path) {
-        relativeFilePath = path;
-    }
-
-    @Override
-    public String getRelativeFilePath() {
-        return relativeFilePath;
-    }
-
-    @Override
-    public String getCodeGenFilePath() {
-        return codeGenDirFilePath;
-    }
-
-    @Override
-    public void setCodeGenFilePath(String path) {
-        codeGenDirFilePath = path;
-    }
-
-    /**
-     * Flush the cached attribute list to the corresponding temporary file.
-     */
-    private void flushCacheAttrToTempFile() {
-
-        for (AttributeInfo attr : getCachedAttributeList()) {
-            JavaFileGenerator.parseAttributeInfo(attr, getGeneratedFileTypes(), getYangName(), getCodeGenFilePath() +
-                    getRelativeFilePath().replace(UtilConstants.PERIOD, UtilConstants.SLASH), this);
-        }
-
-        /*
-         * clear the contents from the cached attribute list.
-         */
-        getCachedAttributeList().clear();
-    }
-
-    @Override
-    public void addAttributeInfo(YangType<?> attrType, String name, boolean isListAttr) {
-        /* YANG name is mapped to java name */
-        name = JavaIdentifierSyntax.getCamelCase(name);
-
-        ImportInfo importInfo = new ImportInfo();
-        boolean isImport = false;
-
-        AttributeInfo newAttr = new AttributeInfo();
-        if (attrType != null) {
-            newAttr.setAttributeType(attrType);
-            String importStr = AttributesJavaDataType.getJavaImportClass(attrType, isListAttr);
-            if (importStr != null) {
-                importInfo.setClassInfo(importStr);
-                importStr = AttributesJavaDataType.getJavaImportPackage(attrType, isListAttr);
-                importInfo.setPkgInfo(importStr);
-                isImport = true;
-            } else {
-                importStr = AttributesJavaDataType.getJavaDataType(attrType);
-                if (importStr == null) {
-                    throw new RuntimeException("not supported data type");
-                    //TODO: need to change to translator exception.
-                }
-                importInfo.setClassInfo(importStr);
-            }
-
-        } else {
-            importInfo.setClassInfo(JavaIdentifierSyntax.getCaptialCase(name));
-            importInfo.setPkgInfo(getRelativeFilePath().replace('/', '.')
-                    + "." + getYangName().toLowerCase());
-            isImport = true;
-        }
-
-        newAttr.setQualifiedName(false);
-        if (isImport) {
-            addImportInfo(importInfo);
-        }
-
-        if (isListAttr) {
-            ImportInfo listImportInfo = new ImportInfo();
-            listImportInfo.setPkgInfo(UtilConstants.COLLECTION_IMPORTS);
-            listImportInfo.setClassInfo(UtilConstants.LIST);
-            addImportInfo(listImportInfo);
-        }
-
-        /**
-         * If two classes with different packages have same class info for import than use qualified name.
-         */
-        for (ImportInfo imports : getImportSet()) {
-            if (imports.getClassInfo().equals(importInfo.getClassInfo())
-                    && !imports.getPkgInfo().equals(importInfo.getPkgInfo())) {
-                newAttr.setQualifiedName(true);
-            }
-        }
-
-        newAttr.setAttributeName(name);
-        newAttr.setListAttr(isListAttr);
-        newAttr.setImportInfo(importInfo);
-
-        if (getCachedAttributeList().size() == MAX_CACHABLE_ATTR) {
-            flushCacheAttrToTempFile();
-        }
-        getCachedAttributeList().add(newAttr);
-    }
-
-    @Override
-    public void close() throws IOException {
-
-        List<AttributeInfo> attrList = getCachedAttributeList();
-        flushCacheAttrToTempFile();
-        String className = getYangName();
-        className = JavaIdentifierSyntax.getCaptialCase(className);
-        String path = getRelativeFilePath();
-        int fileType = getGeneratedFileTypes();
-
-        /*
-         * TODO: add the file header using
-         * JavaCodeSnippetGen.getFileHeaderComment
-         */
-
-        List<String> imports = new ArrayList<>();
-        String importString;
-
-        for (ImportInfo importInfo : new ArrayList<ImportInfo>(getImportSet())) {
-            importString = UtilConstants.IMPORT;
-            if (importInfo.getPkgInfo() != "" && importInfo.getClassInfo() != null
-                    && importInfo.getPkgInfo() != UtilConstants.JAVA_LANG) {
-                importString = importString + importInfo.getPkgInfo() + ".";
-                importString = importString + importInfo.getClassInfo() + UtilConstants.SEMI_COLAN
-                        + UtilConstants.NEW_LINE;
-
-                imports.add(importString);
-            }
-        }
-        java.util.Collections.sort(imports);
-
-        /**
-         * Start generation of files.
-         */
-        if ((fileType & GeneratedFileType.INTERFACE_MASK) != 0
-                || fileType == GeneratedFileType.GENERATE_INTERFACE_WITH_BUILDER) {
-
-            /**
-             * Create interface file.
-             */
-            String interfaceFileName = className;
-            File interfaceFile = JavaFileGenerator.getFileObject(path, interfaceFileName, JAVA_FILE_EXTENSION, this);
-            interfaceFile = JavaFileGenerator.generateInterfaceFile(interfaceFile, className, imports,
-                    attrList, path.replace('/', '.'), this);
-            /**
-             * Create temp builder interface file.
-             */
-            String builderInterfaceFileName = className + UtilConstants.BUILDER + UtilConstants.INTERFACE;
-            File builderInterfaceFile = JavaFileGenerator.getFileObject(path, builderInterfaceFileName,
-                    TEMP_FILE_EXTENSION, this);
-            builderInterfaceFile = JavaFileGenerator.generateBuilderInterfaceFile(builderInterfaceFile, className,
-                    path.replace('/', '.'), attrList, this);
-            /**
-             * Append builder interface file to interface file and close it.
-             */
-            JavaFileGenerator.appendFileContents(builderInterfaceFile, interfaceFile);
-            JavaFileGenerator.insert(interfaceFile,
-                    JavaFileGenerator.closeFile(GeneratedFileType.INTERFACE_MASK, interfaceFileName));
-            /**
-             * Close file handle for interface files.
-             */
-            JavaFileGenerator.closeFileHandles(builderInterfaceFile);
-            JavaFileGenerator.closeFileHandles(interfaceFile);
-
-            /**
-             * Remove temp files.
-             */
-            JavaFileGenerator.clean(builderInterfaceFile);
-        }
-
-        if (!attrList.isEmpty()) {
-            imports.add(UtilConstants.MORE_OBJECT_IMPORT);
-            imports.add(UtilConstants.JAVA_UTIL_OBJECTS_IMPORT);
-            java.util.Collections.sort(imports);
-        }
-
-        if ((fileType & GeneratedFileType.BUILDER_CLASS_MASK) != 0
-                || fileType == GeneratedFileType.GENERATE_INTERFACE_WITH_BUILDER) {
-
-            /**
-             * Create builder class file.
-             */
-            String builderFileName = className + UtilConstants.BUILDER;
-            File builderFile = JavaFileGenerator.getFileObject(path, builderFileName, JAVA_FILE_EXTENSION, this);
-            builderFile = JavaFileGenerator.generateBuilderClassFile(builderFile, className, imports,
-                    path.replace('/', '.'), attrList, this);
-            /**
-             * Create temp impl class file.
-             */
-
-            String implFileName = className + UtilConstants.IMPL;
-            File implTempFile = JavaFileGenerator.getFileObject(path, implFileName, TEMP_FILE_EXTENSION, this);
-            implTempFile = JavaFileGenerator.generateImplClassFile(implTempFile, className,
-                    path.replace('/', '.'), attrList, this);
-            /**
-             * Append impl class to builder class and close it.
-             */
-            JavaFileGenerator.appendFileContents(implTempFile, builderFile);
-            JavaFileGenerator.insert(builderFile,
-                    JavaFileGenerator.closeFile(GeneratedFileType.BUILDER_CLASS_MASK, builderFileName));
-
-            /**
-             * Close file handle for classes files.
-             */
-            JavaFileGenerator.closeFileHandles(implTempFile);
-            JavaFileGenerator.closeFileHandles(builderFile);
-
-            /**
-             * Remove temp files.
-             */
-            JavaFileGenerator.clean(implTempFile);
-        }
-
-        if ((fileType & GeneratedFileType.GENERATE_TYPEDEF_CLASS) != 0) {
-
-            /**
-             * Create builder class file.
-             */
-            String typeDefFileName = className;
-            File typeDefFile = JavaFileGenerator.getFileObject(path, typeDefFileName, JAVA_FILE_EXTENSION, this);
-            typeDefFile = JavaFileGenerator.generateTypeDefClassFile(typeDefFile, className, imports,
-                    path.replace('/', '.'), attrList, this);
-            JavaFileGenerator.insert(typeDefFile,
-                    JavaFileGenerator.closeFile(GeneratedFileType.GENERATE_TYPEDEF_CLASS, typeDefFileName));
-
-            /**
-             * Close file handle for classes files.
-             */
-            JavaFileGenerator.closeFileHandles(typeDefFile);
-        }
-
-        if (!getCachedAttributeList().isEmpty()) {
-            closeTempDataFileHandles(className, getCodeGenFilePath() + getRelativeFilePath());
-            JavaFileGenerator
-                    .cleanTempFiles(new File(getCodeGenFilePath() + getRelativeFilePath() + File.separator + className
-                            + TEMP_FOLDER_NAME_SUFIX));
-        }
-
-        /*
-         * clear the contents from the cached attribute list.
-         */
-        getCachedAttributeList().clear();
-    }
-
-    @Override
-    public void setTempData(String data, TempDataStoreTypes type, String className, String genDir)
-            throws IOException {
-
-        String fileName = "";
-        if (type.equals(TempDataStoreTypes.ATTRIBUTE)) {
-            fileName = ATTRIBUTE_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.GETTER_METHODS)) {
-            fileName = GETTER_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.GETTER_METHODS_IMPL)) {
-            fileName = GETTER_METHOD_IMPL_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.SETTER_METHODS)) {
-            fileName = SETTER_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.SETTER_METHODS_IMPL)) {
-            fileName = SETTER_METHOD_IMPL_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.TYPE_DEF)) {
-            fileName = TYPE_DEF_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.TO_STRING)) {
-            fileName = TO_STRING_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.HASH_CODE)) {
-            fileName = HASH_CODE_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.EQUALS)) {
-            fileName = EQUALS_METHOD_FILE_NAME;
-        } else {
-            fileName = CONSTRUCTOR_FILE_NAME;
-        }
-
-        String path = genDir.replace(UtilConstants.PERIOD, UtilConstants.SLASH)
-                + File.separator + className
-                + TEMP_FOLDER_NAME_SUFIX + File.separator;
-        File dir = new File(path);
-        if (!dir.exists()) {
-            dir.mkdirs();
-        }
-        File file = new File(path + fileName + TEMP_FILE_EXTENSION);
-        try {
-            if (!file.exists()) {
-                file.createNewFile();
-                JavaFileGenerator.insert(file, data);
-            } else {
-                JavaFileGenerator.insert(file, data);
-            }
-        } catch (IOException ex) {
-            throw new IOException("failed to write in temp file.");
-        }
-    }
-
-    @Override
-    public String getTempData(TempDataStoreTypes type, String className, String genDir)
-            throws IOException, FileNotFoundException, ClassNotFoundException {
-
-        String fileName = "";
-        if (type.equals(TempDataStoreTypes.ATTRIBUTE)) {
-            fileName = ATTRIBUTE_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.GETTER_METHODS)) {
-            fileName = GETTER_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.GETTER_METHODS_IMPL)) {
-            fileName = GETTER_METHOD_IMPL_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.SETTER_METHODS)) {
-            fileName = SETTER_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.SETTER_METHODS_IMPL)) {
-            fileName = SETTER_METHOD_IMPL_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.TYPE_DEF)) {
-            fileName = TYPE_DEF_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.TO_STRING)) {
-            fileName = TO_STRING_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.HASH_CODE)) {
-            fileName = HASH_CODE_METHOD_FILE_NAME;
-        } else if (type.equals(TempDataStoreTypes.EQUALS)) {
-            fileName = EQUALS_METHOD_FILE_NAME;
-        } else {
-            fileName = CONSTRUCTOR_FILE_NAME;
-        }
-
-        String path = genDir.replace(UtilConstants.PERIOD, UtilConstants.SLASH)
-                + File.separator + className + TEMP_FOLDER_NAME_SUFIX + File.separator;
-
-        try {
-            String file = path + fileName + TEMP_FILE_EXTENSION;
-            if (new File(file).exists()) {
-                return readFile(path + fileName + TEMP_FILE_EXTENSION);
-            } else {
-                return "";
-            }
-
-        } catch (FileNotFoundException e) {
-            throw new FileNotFoundException("No such file or directory.");
-        }
-    }
-
-    /**
-     * Reads file and convert it to string.
-     *
-     * @param toAppend file to be converted
-     * @return string of file
-     * @throws IOException when fails to convert to string
-     */
-    private static String readFile(String toAppend) throws IOException {
-        BufferedReader bufferReader = new BufferedReader(new FileReader(toAppend));
-        try {
-            StringBuilder stringBuilder = new StringBuilder();
-            String line = bufferReader.readLine();
-
-            while (line != null) {
-                if (line.equals(UtilConstants.FOUR_SPACE_INDENTATION)
-                        || line.equals(UtilConstants.EIGHT_SPACE_INDENTATION)
-                        || line.equals(UtilConstants.SPACE) || line.equals("") || line.equals(UtilConstants.NEW_LINE)) {
-                    stringBuilder.append("\n");
-                } else {
-                    stringBuilder.append(line);
-                    stringBuilder.append("\n");
-                }
-                line = bufferReader.readLine();
-            }
-            return stringBuilder.toString();
-        } finally {
-            bufferReader.close();
-        }
-    }
-
-    /**
-     * Closes the temp file handles.
-     *
-     * @param className class name
-     * @param genDir generated directory
-     * @throws IOException when failes to close file handle
-     */
-    private void closeTempDataFileHandles(String className, String genDir)
-            throws IOException {
-
-        String path = genDir.replace(UtilConstants.PERIOD, UtilConstants.SLASH) + File.separator + className
-                + TEMP_FOLDER_NAME_SUFIX + File.separator;
-
-        String fileName = "";
-        fileName = ATTRIBUTE_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = GETTER_METHOD_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = GETTER_METHOD_IMPL_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = SETTER_METHOD_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = SETTER_METHOD_IMPL_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = TYPE_DEF_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = TO_STRING_METHOD_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = HASH_CODE_METHOD_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = EQUALS_METHOD_FILE_NAME;
-        closeTempFile(fileName, path);
-
-        fileName = CONSTRUCTOR_FILE_NAME;
-        closeTempFile(fileName, path);
-    }
-
-    /**
-     * Closes the specific temp file.
-     *
-     * @param fileName temp file name
-     * @param path path
-     * @throws IOException when failed to close file handle
-     */
-    private void closeTempFile(String fileName, String path) throws IOException {
-        File file = new File(path + fileName + TEMP_FILE_EXTENSION);
-        try {
-            if (!file.exists()) {
-                FileSystemUtil.updateFileHandle(file, null, true);
-            }
-        } catch (IOException ex) {
-            throw new IOException("failed to close the temp file handle.");
-        }
-    }
-}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java b/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java
new file mode 100644
index 0000000..403ef5c
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java
@@ -0,0 +1,59 @@
+/*
+ * 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;
+
+/**
+ * Type of files generated.
+ */
+public final class GeneratedJavaFileType {
+
+    /**
+     * prevent creating attributes.
+     */
+    private GeneratedJavaFileType() {
+    }
+
+    /**
+     * Interface file.
+     */
+    public static final int INTERFACE_MASK = 1;
+
+    /**
+     * Builder interface file.
+     */
+    public static final int BUILDER_INTERFACE_MASK = 2;
+
+    /**
+     * Builder class file.
+     */
+    public static final int BUILDER_CLASS_MASK = 4;
+
+    /**
+     * Impl class file.
+     */
+    public static final int IMPL_CLASS_MASK = 8;
+
+    /**
+     * Interface and class file.
+     */
+    public static final int GENERATE_INTERFACE_WITH_BUILDER = 15;
+
+    /**
+     * Java class corresponding to typedef.
+     */
+    public static final int GENERATE_TYPEDEF_CLASS = 16;
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java b/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
new file mode 100644
index 0000000..ae337bc
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
@@ -0,0 +1,74 @@
+/*
+ * 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;
+
+/**
+ * Type of files generated.
+ */
+public final class GeneratedTempFileType {
+
+    /**
+     * prevent creating attributes.
+     */
+    private GeneratedTempFileType() {
+    }
+
+    /**
+     * attributes definition temporary file.
+     */
+    public static final int ATTRIBUTES_MASK = 1;
+
+    /**
+     * getter methods for interface.
+     */
+    public static final int GETTER_FOR_INTERFACE_MASK = 2;
+
+    /**
+     * getter methods for class.
+     */
+    public static final int GETTER_FOR_CLASS_MASK = 4;
+
+    /**
+     * setter methods for interface.
+     */
+    public static final int SETTER_FOR_INTERFACE_MASK = 8;
+
+    /**
+     * setter methods for class.
+     */
+    public static final int SETTER_FOR_CLASS_MASK = 16;
+
+    /**
+     * constructor method of class.
+     */
+    public static final int CONSTRUCTOR_IMPL_MASK = 32;
+
+    /**
+     * hash code implementation of class.
+     */
+    public static final int HASH_CODE_IMPL_MASK = 64;
+
+    /**
+     * equals implementation of class.
+     */
+    public static final int EQUALS_IMPL_MASK = 128;
+
+    /**
+     * to string implementation of class.
+     */
+    public static final int TO_STRING_IMPL_MASK = 256;
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaFileInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaFileInfo.java
new file mode 100644
index 0000000..e6fa482
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaFileInfo.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * Data model nodes which are required to generate java classes, need to support
+ * java file info.
+ */
+public interface HasJavaFileInfo {
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    public JavaFileInfo getJavaFileInfo();
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    public void setJavaFileInfo(JavaFileInfo javaInfo);
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaImportData.java b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaImportData.java
new file mode 100644
index 0000000..ac29cdf
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/HasJavaImportData.java
@@ -0,0 +1,36 @@
+/*
+ * 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;
+
+/**
+ * Maintains the information of the java import data.
+ */
+public interface HasJavaImportData {
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    public JavaImportData getJavaImportData();
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    public void setJavaImportData(JavaImportData javaImportData);
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/HasTempJavaCodeFragmentFiles.java b/src/main/java/org/onosproject/yangutils/translator/tojava/HasTempJavaCodeFragmentFiles.java
new file mode 100644
index 0000000..f05e8ec
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/HasTempJavaCodeFragmentFiles.java
@@ -0,0 +1,35 @@
+/*
+ * 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;
+
+/**
+ * Has temporary file handle.
+ */
+public interface HasTempJavaCodeFragmentFiles {
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles();
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle);
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/ImportInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/ImportInfo.java
deleted file mode 100644
index 693bbcb..0000000
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/ImportInfo.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * 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;
-
-import java.util.Objects;
-
-import com.google.common.base.MoreObjects;
-
-/**
- * Maintains the information about individual imports in the generated file.
- */
-public class ImportInfo implements Comparable {
-
-    /**
-     * Package location where the imported class/interface is defined.
-     */
-    private String pkgInfo;
-
-    /**
-     * Class/interface being referenced.
-     */
-    private String classInfo;
-
-    /**
-     * Default constructor.
-     */
-    public ImportInfo() {
-    }
-
-    /**
-     * Get the imported package info.
-     *
-     * @return the imported package info
-     */
-    public String getPkgInfo() {
-        return pkgInfo;
-    }
-
-    /**
-     * Set the imported package info.
-     *
-     * @param pkgInfo the imported package info
-     */
-    public void setPkgInfo(String pkgInfo) {
-        this.pkgInfo = pkgInfo;
-    }
-
-    /**
-     * Get the imported class/interface info.
-     *
-     * @return the imported class/interface info
-     */
-    public String getClassInfo() {
-        return classInfo;
-    }
-
-    /**
-     * Set the imported class/interface info.
-     *
-     * @param classInfo the imported class/interface info
-     */
-    public void setClassInfo(String classInfo) {
-        this.classInfo = classInfo;
-    }
-
-    @Override
-    public int hashCode() {
-        return Objects.hash(pkgInfo, classInfo);
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj instanceof ImportInfo) {
-            ImportInfo other = (ImportInfo) obj;
-            return Objects.equals(pkgInfo, other.pkgInfo) &&
-                    Objects.equals(classInfo, other.classInfo);
-        }
-        return false;
-    }
-
-    /**
-     * check if the import info matches.
-     *
-     * @param importInfo matched import
-     * @return if equal or not
-     */
-    public boolean exactMatch(ImportInfo importInfo) {
-        return equals(importInfo)
-                && Objects.equals(pkgInfo, importInfo.getPkgInfo())
-                && Objects.equals(classInfo, importInfo.getClassInfo());
-    }
-
-    @Override
-    public String toString() {
-        return MoreObjects.toStringHelper(getClass())
-                .add("pkgInfo", pkgInfo)
-                .add("classInfo", classInfo).toString();
-    }
-
-    /**
-     * Check that there is no 2 objects with the same class name.
-     *
-     * @param o compared import info.
-     */
-    @Override
-    public int compareTo(Object o) {
-        ImportInfo other;
-        if (o instanceof ImportInfo) {
-            other = (ImportInfo) o;
-        } else {
-            return -1;
-        }
-        return getClassInfo().compareTo(other.getClassInfo());
-    }
-
-}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
new file mode 100644
index 0000000..3ce39d9
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
@@ -0,0 +1,249 @@
+/*
+ * 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;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangType;
+
+import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getIsQualifiedAccessOrAddToImportList;
+import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
+import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfLeafAttribute;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+
+/**
+ * Maintains the attribute info corresponding to class/interface generated.
+ */
+public final class JavaAttributeInfo {
+
+    /**
+     * The data type info of attribute.
+     */
+    private YangType<?> attrType;
+
+    /**
+     * Name of the attribute.
+     */
+    private String name;
+
+    /**
+     * If the added attribute is a list of info.
+     */
+    private boolean isListAttr = false;
+
+    /**
+     * If the added attribute has to be accessed in a fully qualified manner.
+     */
+    private boolean isQualifiedName = false;
+
+    /**
+     * The class info will be used to set the attribute type and package info
+     * will be use for qualified name.
+     */
+    private JavaQualifiedTypeInfo importInfo;
+
+    /**
+     * Default constructor.
+     */
+    private JavaAttributeInfo() {
+    }
+
+    /**
+     * Get the data type info of attribute.
+     *
+     * @return the data type info of attribute
+     */
+    public YangType<?> getAttributeType() {
+
+        if (attrType == null) {
+            throw new RuntimeException("Expected java attribute type is null");
+        }
+        return attrType;
+    }
+
+    /**
+     * Set the data type info of attribute.
+     *
+     * @param type the data type info of attribute
+     */
+    public void setAttributeType(YangType<?> type) {
+
+        attrType = type;
+    }
+
+    /**
+     * Get name of the attribute.
+     *
+     * @return name of the attribute
+     */
+    public String getAttributeName() {
+
+        if (name == null) {
+            throw new RuntimeException("Expected java attribute name is null");
+        }
+        return name;
+    }
+
+    /**
+     * Set name of the attribute.
+     *
+     * @param attrName name of the attribute
+     */
+    public void setAttributeName(String attrName) {
+
+        name = attrName;
+    }
+
+    /**
+     * Get if the added attribute is a list of info.
+     *
+     * @return the if the added attribute is a list of info
+     */
+    public boolean isListAttr() {
+
+        return isListAttr;
+    }
+
+    /**
+     * Set if the added attribute is a list of info.
+     *
+     * @param isList if the added attribute is a list of info
+     */
+    public void setListAttr(boolean isList) {
+
+        isListAttr = isList;
+    }
+
+    /**
+     * Get if the added attribute has to be accessed in a fully qualified
+     * manner.
+     *
+     * @return the if the added attribute has to be accessed in a fully
+     *         qualified manner.
+     */
+    public boolean isQualifiedName() {
+
+        return isQualifiedName;
+    }
+
+    /**
+     * Set if the added attribute has to be accessed in a fully qualified
+     * manner.
+     *
+     * @param isQualified if the added attribute has to be accessed in a fully
+     *            qualified manner
+     */
+    public void setIsQualifiedAccess(boolean isQualified) {
+
+        isQualifiedName = isQualified;
+    }
+
+    /**
+     * Get the import info for the attribute type. It will be null, of the type
+     * is basic built-in java type.
+     *
+     * @return import info
+     */
+    public JavaQualifiedTypeInfo getImportInfo() {
+
+        return importInfo;
+    }
+
+    /**
+     * Set the import info for the attribute type.
+     *
+     * @param importInfo import info for the attribute type
+     */
+    public void setImportInfo(JavaQualifiedTypeInfo importInfo) {
+
+        this.importInfo = importInfo;
+    }
+
+    /**
+     * Create an attribute info object corresponding to the passed leaf
+     * information and return it.
+     *
+     * @param curNode current data model node for which the java file is being
+     *            generated
+     * @param attributeType leaf data type
+     * @param attributeName leaf name
+     * @param isListAttribute is the current added attribute needs to be a list
+     * @return AttributeInfo attribute details required to add in temporary
+     *         files
+     */
+    public static JavaAttributeInfo getAttributeInfoOfLeaf(YangNode curNode,
+            YangType<?> attributeType, String attributeName,
+            boolean isListAttribute) {
+
+        JavaAttributeInfo newAttr = new JavaAttributeInfo();
+
+        /*
+         * Get the import info corresponding to the attribute for import in
+         * generated java files or qualified access
+         */
+        JavaQualifiedTypeInfo importInfo = getQualifiedTypeInfoOfLeafAttribute(curNode,
+                attributeType, attributeName, isListAttribute);
+        newAttr.setImportInfo(importInfo);
+        newAttr.setIsQualifiedAccess(getIsQualifiedAccessOrAddToImportList(
+                curNode, importInfo));
+        newAttr.setAttributeName(getCamelCase(attributeName));
+        newAttr.setListAttr(isListAttribute);
+        newAttr.setImportInfo(importInfo);
+        newAttr.setAttributeType(attributeType);
+
+        return newAttr;
+    }
+
+    /**
+     * Create an attribute info object corresponding to a data model node and
+     * return it.
+     *
+     * @param curNode current data model node for which the java code generation
+     *            is being handled
+     * @param parentNode parent node in which the current node is an attribute
+     * @param isListNode is the current added attribute needs to be a list
+     * @return AttributeInfo attribute details required to add in temporary
+     *         files
+     */
+    public static JavaAttributeInfo getCurNodeAsAttributeInParent(
+            YangNode curNode, YangNode parentNode, boolean isListNode) {
+
+        JavaAttributeInfo newAttr = new JavaAttributeInfo();
+
+        //        if (curNode instanceof HasJavaFileInfo) {
+        //          throw new RuntimeException("translator data model node does not have java info");
+        //    }
+
+        String curNodeName = ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName();
+
+        /*
+         * Get the import info corresponding to the attribute for import in
+         * generated java files or qualified access
+         */
+        JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(parentNode,
+                curNodeName, isListNode);
+        newAttr.setImportInfo(qualifiedTypeInfo);
+        newAttr.setIsQualifiedAccess(
+                getIsQualifiedAccessOrAddToImportList(parentNode,
+                        qualifiedTypeInfo));
+        newAttr.setAttributeName(getCamelCase(curNodeName));
+        newAttr.setListAttr(isListNode);
+        newAttr.setImportInfo(qualifiedTypeInfo);
+        newAttr.setAttributeType(null);
+
+        return newAttr;
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
index 40e4f1e..4ecb916 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
@@ -18,46 +18,24 @@
 
 import java.io.IOException;
 
-import org.onosproject.yangutils.datamodel.YangNode;
-
 /**
- * Implementation of Java code generator based on application schema.
+ * Abstraction of an entity which provides Code generator functionalities.
  */
-public final class JavaCodeGenerator {
+public interface JavaCodeGenerator {
 
     /**
-     * Default constructor.
-     */
-    private JavaCodeGenerator() {
-    }
-
-    /**
-     * Generate Java code files corresponding to the YANG schema.
+     * Traverse the schema of application and generate corresponding code.
      *
-     * @param rootNode root node of the data model tree
      * @param codeGenDir code generation directory
-     * @throws IOException when fails to generate java code file the current node
+     * @throws IOException when fails to translate the data model tree
      */
-    public static void generateJavaCode(YangNode rootNode, String codeGenDir) throws IOException {
-        YangNode curNode = rootNode;
-        TraversalType curTraversal = TraversalType.ROOT;
+    void generateCodeEntry(String codeGenDir) throws IOException;
 
-        while (!(curNode == null)) {
-            if (curTraversal != TraversalType.PARENT) {
-                curNode.generateJavaCodeEntry(codeGenDir);
-            }
-            if (curTraversal != TraversalType.PARENT && curNode.getChild() != null) {
-                curTraversal = TraversalType.CHILD;
-                curNode = curNode.getChild();
-            } else if (curNode.getNextSibling() != null) {
-                curNode.generateJavaCodeExit();
-                curTraversal = TraversalType.SIBILING;
-                curNode = curNode.getNextSibling();
-            } else {
-                curNode.generateJavaCodeExit();
-                curTraversal = TraversalType.PARENT;
-                curNode = curNode.getParent();
-            }
-        }
-    }
+    /**
+     * Traverse the schema of application and generate corresponding code.
+     *
+     * @throws IOException when fails to generate java code
+     */
+    void generateCodeExit() throws IOException;
+
 }
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
new file mode 100644
index 0000000..40fed6e
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGeneratorUtil.java
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+
+/**
+ * Implementation of Java code generator based on application schema.
+ */
+public final class JavaCodeGeneratorUtil {
+
+    /**
+     * Default constructor.
+     */
+    private JavaCodeGeneratorUtil() {
+    }
+
+    /**
+     * Generate Java code files corresponding to the YANG schema.
+     *
+     * @param rootNode root node of the data model tree
+     * @param codeGenDir code generation directory
+     * @throws IOException when fails to generate java code file the current
+     *             node
+     */
+    public static void generateJavaCode(YangNode rootNode, String codeGenDir) throws IOException {
+        YangNode curNode = rootNode;
+        TraversalType curTraversal = TraversalType.ROOT;
+
+        while (!(curNode == null)) {
+            if (curTraversal != TraversalType.PARENT) {
+                generateCodeEntry(curNode, codeGenDir);
+            }
+            if (curTraversal != TraversalType.PARENT && curNode.getChild() != null) {
+                curTraversal = TraversalType.CHILD;
+                curNode = curNode.getChild();
+            } else if (curNode.getNextSibling() != null) {
+                generateCodeExit(curNode);
+                curTraversal = TraversalType.SIBILING;
+                curNode = curNode.getNextSibling();
+            } else {
+                generateCodeExit(curNode);
+                curTraversal = TraversalType.PARENT;
+                curNode = curNode.getParent();
+            }
+        }
+    }
+
+    /**
+     * Generates the current nodes code snippet.
+     *
+     * @param curNode current data model node for which the code needs to be
+     *            generated
+     * @param codeGenDir the base directory where the code needs to be generated
+     * @throws IOException IO operation exception
+     */
+    private static void generateCodeEntry(YangNode curNode,
+            String codeGenDir) throws IOException {
+
+        if (curNode instanceof JavaCodeGenerator) {
+            ((JavaCodeGenerator) curNode).generateCodeEntry(codeGenDir);
+        } else {
+            throw new RuntimeException(
+                    "Gnenerated data model node cannot be translated to target language code");
+        }
+    }
+
+    /**
+     * Generates the current nodes code target code from the snippet.
+     *
+     * @param curNode current data model node for which the code needs to be
+     *            generated
+     * @throws IOException IO operation exception
+     */
+    private static void generateCodeExit(YangNode curNode) throws IOException {
+
+        if (curNode instanceof JavaCodeGenerator) {
+            ((JavaCodeGenerator) curNode).generateCodeExit();
+        } else {
+            throw new RuntimeException(
+                    "Gnenerated data model node cannot be translated to target language code");
+        }
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaFileInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaFileInfo.java
new file mode 100644
index 0000000..8b69fca
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaFileInfo.java
@@ -0,0 +1,146 @@
+/*
+ * 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;
+
+/**
+ * Cached java file handle, which supports the addition of member attributes and
+ * methods.
+ */
+public class JavaFileInfo {
+    /**
+     * The type(s) of java source file(s) to be generated when the cached file
+     * handle is closed.
+     */
+    private int genFileTypes;
+
+    /**
+     * Name of the module.
+     */
+    private String javaName;
+
+    /**
+     * java Package of the mapped java class.
+     */
+    private String pkg;
+
+    /**
+     * File generation directory path.
+     */
+    private String relativeFilePath;
+
+    /**
+     * File generation base directory path.
+     */
+    private String codeGenDirFilePath;
+
+    /**
+     * Get the types of files being generated corresponding to the YANG
+     * definition.
+     *
+     * @return the types of files being generated corresponding to the YANG
+     *         definition
+     */
+    public int getGeneratedFileTypes() {
+        return genFileTypes;
+    }
+
+    /**
+     * Set the types of files being generated corresponding to the YANG
+     * definition.
+     *
+     * @param fileTypes the types of files being generated corresponding to the
+     *            YANG definition
+     */
+    public void setGeneratedFileTypes(int fileTypes) {
+        genFileTypes = fileTypes;
+    }
+
+    /**
+     * Get the java name of the node.
+     *
+     * @return the java name of node
+     */
+    public String getJavaName() {
+        return javaName;
+    }
+
+    /**
+     * Set the java name of the node.
+     *
+     * @param name the java name of node
+     */
+    public void setJavaName(String name) {
+        javaName = name;
+    }
+
+    /**
+     * Get the mapped java package.
+     *
+     * @return the java package
+     */
+    public String getPackage() {
+        if (pkg == null) {
+            throw new RuntimeException("Referencing package of a generated java file which is not set");
+        }
+        return pkg;
+    }
+
+    /**
+     * Set the node's package.
+     *
+     * @param nodePackage node's package
+     */
+    public void setPackage(String nodePackage) {
+        pkg = nodePackage;
+    }
+
+    /**
+     * Sets directory package path for code generation.
+     *
+     * @param path directory package path for code generation
+     */
+    public void setPackageFilePath(String path) {
+        relativeFilePath = path;
+    }
+
+    /**
+     * Gets directory package path for code generation.
+     *
+     * @return directory package path for code generation
+     */
+    public String getPackageFilePath() {
+        return relativeFilePath;
+    }
+
+    /**
+     * Gets base directory package path for code generation.
+     *
+     * @return directory package path for code generation
+     */
+    public String getBaseCodeGenPath() {
+        return codeGenDirFilePath;
+    }
+
+    /**
+     * Sets base directory package path for code generation.
+     *
+     * @param path base directory path
+     */
+    public void setBaseCodeGenPath(String path) {
+        codeGenDirFilePath = path;
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
new file mode 100644
index 0000000..2fffe62
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaImportData.java
@@ -0,0 +1,111 @@
+/*
+ * 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;
+
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+
+/**
+ * Generated Java file can contain imports.
+ */
+public class JavaImportData {
+
+    /**
+     * Flag to denote if any list in imported.
+     */
+    private boolean isListToImport;
+
+    /**
+     * Sorted set of import info, to be used to maintain the set of classes to
+     * be imported in the generated class.
+     */
+    private SortedSet<JavaQualifiedTypeInfo> importSet;
+
+    /**
+     * Default constructor.
+     */
+    public JavaImportData() {
+        setImportSet(new TreeSet<JavaQualifiedTypeInfo>());
+    }
+
+    /**
+     * Get if the list needs to be imported.
+     *
+     * @return true if any of the attribute needs to be maintained as a list.
+     */
+    public boolean getIfListImported() {
+        return isListToImport;
+    }
+
+    /**
+     * Set the status of importing list.
+     *
+     * @param isList status to mention list is bing imported.
+     */
+    public void setIfListImported(boolean isList) {
+        isListToImport = isList;
+    }
+
+    /**
+     * Get the set containing the imported class/interface info.
+     *
+     * @return the set containing the imported class/interface info
+     */
+    public SortedSet<JavaQualifiedTypeInfo> getImportSet() {
+        return importSet;
+    }
+
+    /**
+     * Assign the set containing the imported class/interface info.
+     *
+     * @param importSet the set containing the imported class/interface info
+     */
+    private void setImportSet(SortedSet<JavaQualifiedTypeInfo> importSet) {
+        this.importSet = importSet;
+    }
+
+    /**
+     * Add an imported class/interface info if it is not already part of the
+     * collection.
+     *
+     * If already part of the collection, check if the packages are same, if so
+     * then return true, to denote it is already in the import collection, and
+     * it can be accessed without qualified access. If the packages do not
+     * match, then do not add to the import collection, and return false to
+     * denote, it is not added to import collection and needs to be accessed in
+     * a qualified manner.
+     *
+     * @param curNode current data model node
+     * @param newImportInfo class/interface info being imported
+     * @return status of new addition of class/interface to the import set
+     */
+    public boolean addImportInfo(YangNode curNode, JavaQualifiedTypeInfo newImportInfo) {
+        if (!(curNode instanceof HasJavaImportData)) {
+            throw new RuntimeException("missing import info in data model node");
+        }
+        for (JavaQualifiedTypeInfo curImportInfo : ((HasJavaImportData) curNode).getJavaImportData().getImportSet()) {
+            if (curImportInfo.getClassInfo()
+                    .contentEquals(newImportInfo.getClassInfo())) {
+                return curImportInfo.getPkgInfo()
+                        .contentEquals(newImportInfo.getPkgInfo());
+            }
+        }
+        ((HasJavaImportData) curNode).getJavaImportData().getImportSet().add(newImportInfo);
+        return true;
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
new file mode 100644
index 0000000..ba4b99b
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
@@ -0,0 +1,303 @@
+/*
+ * 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;
+
+import java.util.Objects;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Maintains the information about individual imports in the generated file.
+ */
+public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> {
+
+    /**
+     * Package location where the imported class/interface is defined.
+     */
+    private String pkgInfo;
+
+    /**
+     * Class/interface being referenced.
+     */
+    private String classInfo;
+
+    /**
+     * Default constructor.
+     */
+    public JavaQualifiedTypeInfo() {
+    }
+
+    /**
+     * Get the imported package info.
+     *
+     * @return the imported package info
+     */
+    public String getPkgInfo() {
+
+        return pkgInfo;
+    }
+
+    /**
+     * Set the imported package info.
+     *
+     * @param pkgInfo the imported package info
+     */
+    public void setPkgInfo(String pkgInfo) {
+
+        this.pkgInfo = pkgInfo;
+    }
+
+    /**
+     * Get the imported class/interface info.
+     *
+     * @return the imported class/interface info
+     */
+    public String getClassInfo() {
+
+        return classInfo;
+    }
+
+    /**
+     * Set the imported class/interface info.
+     *
+     * @param classInfo the imported class/interface info
+     */
+    public void setClassInfo(String classInfo) {
+
+        this.classInfo = classInfo;
+    }
+
+    /**
+     * Get the import info for an attribute, which needs to be used for code
+     * generation for import or for qualified access.
+     *
+     * @param curNode current data model node for which the java file is being
+     *            generated.
+     * @param attrType type of attribute being added, it will be null, when the
+     *            child class is added as an attribute
+     * @param attributeName name of the attribute being added, it will used in
+     *            import info for child class.
+     * @param isListAttr is the added attribute going to be used as a list
+     * @return return the import info for this attribute
+     */
+    public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfLeafAttribute(YangNode curNode,
+            YangType<?> attrType, String attributeName,
+            boolean isListAttr) {
+
+        JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo();
+
+        if (attrType == null) {
+            throw new RuntimeException("missing data type of leaf " + attributeName);
+        }
+
+        /*
+         * Current leaves holder is adding a leaf info as a attribute to the
+         * current class.
+         */
+        String className = AttributesJavaDataType.getJavaImportClass(attrType, isListAttr);
+        if (className != null) {
+            /*
+             * Corresponding to the attribute type a class needs to be imported,
+             * since it can be a derived type or a usage of wrapper classes.
+             */
+            importInfo.setClassInfo(className);
+            String classPkg = AttributesJavaDataType.getJavaImportPackage(attrType, isListAttr, className);
+            if (classPkg == null) {
+                throw new RuntimeException("import package cannot be null when the class is used");
+            }
+            importInfo.setPkgInfo(classPkg);
+        } else {
+            /*
+             * The attribute does not need a class to be imported, for example
+             * built in java types.
+             */
+            String dataTypeName = AttributesJavaDataType.getJavaDataType(attrType);
+            if (dataTypeName == null) {
+                throw new RuntimeException("not supported data type");
+            }
+            importInfo.setClassInfo(dataTypeName);
+        }
+        return importInfo;
+    }
+
+    /**
+     * Get the import info for an attribute, which needs to be used for code
+     * generation for import or for qualified access.
+     *
+     * @param curNode current data model node for which the java file is being
+     *            generated.
+     * @param attributeName name of the attribute being added, it will used in
+     *            import info for child class.
+     * @param isListAttr is the added attribute going to be used as a list
+     * @return return the import info for this attribute
+     */
+    public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfCurNode(YangNode curNode,
+            String attributeName, boolean isListAttr) {
+
+        JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo();
+
+        if (!(curNode instanceof HasJavaFileInfo)) {
+            throw new RuntimeException("missing java file information to get the package details "
+                    + "of attribute corresponding to child node");
+        }
+        /*
+         * The scenario when we need to add the child class as an attribute in
+         * the current class. The child class is in the package of the current
+         * classes package with current classes name.
+         */
+        importInfo.setClassInfo(attributeName);
+        importInfo.setPkgInfo((((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage() + "."
+                + ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName()).toLowerCase());
+
+        return importInfo;
+    }
+
+    /**
+     * Get if the attribute needs to be accessed in a qualified manner or not,
+     * if it needs to be imported, then the same needs to be done.
+     *
+     * @param curNode current cache of the data model node for which java file
+     *            is bing generated
+     * @param importInfo import info for the current attribute being added
+     * @return status of the qualified access to the attribute
+     */
+    public static boolean getIsQualifiedAccessOrAddToImportList(YangNode curNode,
+            JavaQualifiedTypeInfo importInfo) {
+
+        boolean isImportPkgEqualCurNodePkg;
+        if (!(curNode instanceof HasJavaFileInfo)) {
+            throw new RuntimeException("missing java file info for getting the qualified access");
+        }
+        if (importInfo.getClassInfo().contentEquals(
+                ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName())) {
+            /*
+             * if the current class name is same as the attribute class name,
+             * then the attribute must be accessed in a qualified manner.
+             */
+            return true;
+        } else if (importInfo.getPkgInfo() != null) {
+            /*
+             * If the attribute type is having the package info, it is contender
+             * for import list and also need to check if it needs to be a
+             * qualified access.
+             */
+            isImportPkgEqualCurNodePkg = isImportPkgEqualCurNodePkg(curNode, importInfo);
+            if (!isImportPkgEqualCurNodePkg) {
+                /*
+                 * If the package of the attribute added is not same as the
+                 * current class package, then it must either be imported for
+                 * access or it must be a qualified access.
+                 */
+                if (!(curNode instanceof HasJavaImportData)) {
+                    /*
+                     * If the current data model node is not supposed to import
+                     * data, then this is a usage issue and needs to be fixed.
+                     */
+                    throw new RuntimeException("Current node needs to support Imports");
+                }
+
+                boolean isImportAdded = ((HasJavaImportData) curNode).getJavaImportData()
+                        .addImportInfo(curNode, importInfo);
+                if (!isImportAdded) {
+                    /*
+                     * If the attribute type info is not imported, then it must
+                     * be a qualified access.
+                     */
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Check if the import info is same as the package of the current generated
+     * java file.
+     *
+     * @param curNode Java identifier of the current data model node
+     * @param importInfo import info for an attribute
+     * @return true if the import info is same as the current nodes package
+     *         false otherwise
+     */
+    public static boolean isImportPkgEqualCurNodePkg(
+            YangNode curNode, JavaQualifiedTypeInfo importInfo) {
+
+        if (!(curNode instanceof HasJavaFileInfo)) {
+            throw new RuntimeException("missing java file info for the data model node");
+        }
+        return ((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage()
+                .contentEquals(importInfo.getPkgInfo()
+                        + "." + importInfo.getClassInfo());
+    }
+
+    @Override
+    public int hashCode() {
+
+        return Objects.hash(pkgInfo, classInfo);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof JavaQualifiedTypeInfo) {
+            JavaQualifiedTypeInfo other = (JavaQualifiedTypeInfo) obj;
+            return Objects.equals(pkgInfo, other.pkgInfo) &&
+                    Objects.equals(classInfo, other.classInfo);
+        }
+        return false;
+    }
+
+    /**
+     * check if the import info matches.
+     *
+     * @param importInfo matched import
+     * @return if equal or not
+     */
+    public boolean exactMatch(JavaQualifiedTypeInfo importInfo) {
+
+        return equals(importInfo)
+                && Objects.equals(pkgInfo, importInfo.getPkgInfo())
+                && Objects.equals(classInfo, importInfo.getClassInfo());
+    }
+
+    @Override
+    public String toString() {
+
+        return MoreObjects.toStringHelper(getClass())
+                .add("pkgInfo", pkgInfo)
+                .add("classInfo", classInfo).toString();
+    }
+
+    /**
+     * Check that there is no 2 objects with the same class name.
+     *
+     * @param other compared import info.
+     */
+    @Override
+    public int compareTo(JavaQualifiedTypeInfo other) {
+
+        return getClassInfo().compareTo(other.getClassInfo());
+    }
+
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
new file mode 100644
index 0000000..5ff4e79
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
@@ -0,0 +1,874 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangLeavesHolder;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator;
+import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
+import org.onosproject.yangutils.utils.UtilConstants;
+import org.onosproject.yangutils.utils.io.impl.FileSystemUtil;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoOfLeaf;
+import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getCurNodeAsAttributeInParent;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaAttributeDefination;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructor;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterForClass;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getGetterString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterForClass;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getSetterString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethod;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
+
+/**
+ * Provides implementation of java code fragments temporary implementations.
+ */
+public class TempJavaCodeFragmentFiles {
+
+    /**
+     * The variable which guides the types of temporary files generated using
+     * the temporary generated file types mask.
+     */
+    private int generatedTempFiles;
+
+    /**
+     * Absolute path where the target java file needs to be generated.
+     */
+    private String absoluteDirPath;
+
+    /**
+     * Name of java file that needs to be generated.
+     */
+    private String generatedJavaClassName;
+
+    /**
+     * File type extension for temporary classes.
+     */
+    private static final String TEMP_FILE_EXTENSION = ".tmp";
+
+    /**
+     * Folder suffix for temporary files folder.
+     */
+    private static final String TEMP_FOLDER_NAME_SUFIX = "-Temp";
+
+    /**
+     * File name for getter method.
+     */
+    private static final String GETTER_METHOD_FILE_NAME = "GetterMethod";
+
+    /**
+     * File name for getter method implementation.
+     */
+    private static final String GETTER_METHOD_IMPL_FILE_NAME = "GetterMethodImpl";
+
+    /**
+     * File name for setter method.
+     */
+    private static final String SETTER_METHOD_FILE_NAME = "SetterMethod";
+
+    /**
+     * File name for setter method implementation.
+     */
+    private static final String SETTER_METHOD_IMPL_FILE_NAME = "SetterMethodImpl";
+
+    /**
+     * File name for constructor.
+     */
+    private static final String CONSTRUCTOR_FILE_NAME = "Constructor";
+
+    /**
+     * File name for attributes.
+     */
+    private static final String ATTRIBUTE_FILE_NAME = "Attributes";
+
+    /**
+     * File name for to string method.
+     */
+    private static final String TO_STRING_METHOD_FILE_NAME = "ToString";
+
+    /**
+     * File name for hash code method.
+     */
+    private static final String HASH_CODE_METHOD_FILE_NAME = "HashCode";
+
+    /**
+     * File name for equals method.
+     */
+    private static final String EQUALS_METHOD_FILE_NAME = "Equals";
+
+    /**
+     * Temporary file handle for attribute.
+     */
+    private File attributesTempFileHandle;
+
+    /**
+     * Temporary file handle for getter of interface.
+     */
+    private File getterInterfaceTempFileHandle;
+
+    /**
+     * Temporary file handle for getter of class.
+     */
+    private File getterImplTempFileHandle;
+
+    /**
+     * Temporary file handle for setter of interface.
+     */
+    private File setterInterfaceTempFileHandle;
+
+    /**
+     * Temporary file handle for setter of class.
+     */
+    private File setterImplTempFileHandle;
+
+    /**
+     * Temporary file handle for constructor of class.
+     */
+    private File constructorImplTempFileHandle;
+
+    /**
+     * Temporary file handle for hash code method of class.
+     */
+    private File hashCodeImplTempFileHandle;
+
+    /**
+     * Temporary file handle for equals method of class.
+     */
+    private File equalsImplTempFileHandle;
+
+    /**
+     * Temporary file handle for to string method of class.
+     */
+    private File toStringImplTempFileHandle;
+
+    /**
+     * Construct an object of temporary java code fragment.
+     *
+     * @param genFileType file generation type
+     * @param genDir file generation directory
+     * @param className class name
+     * @throws IOException when fails to create new file handle
+     */
+    public TempJavaCodeFragmentFiles(int genFileType, String genDir, String className) throws IOException {
+
+        generatedTempFiles = 0;
+        absoluteDirPath = genDir;
+        generatedJavaClassName = className;
+
+        /**
+         * Initialize getter when generation file type matches to interface
+         * mask.
+         */
+        if ((genFileType & INTERFACE_MASK) != 0) {
+            generatedTempFiles |= GETTER_FOR_INTERFACE_MASK;
+        }
+
+        /**
+         * Initialize getter and setter when generation file type matches to
+         * builder interface mask.
+         */
+        if ((genFileType & BUILDER_INTERFACE_MASK) != 0) {
+            generatedTempFiles |= GETTER_FOR_INTERFACE_MASK;
+            generatedTempFiles |= SETTER_FOR_INTERFACE_MASK;
+        }
+
+        /**
+         * Initialize getterImpl, setterImpl and attributes when generation file
+         * type matches to builder class mask.
+         */
+        if ((genFileType & BUILDER_CLASS_MASK) != 0) {
+            generatedTempFiles |= ATTRIBUTES_MASK;
+            generatedTempFiles |= GETTER_FOR_CLASS_MASK;
+            generatedTempFiles |= SETTER_FOR_CLASS_MASK;
+        }
+
+        /**
+         * Initialize getterImpl, attributes, constructor, hash code, equals and
+         * to strings when generation file type matches to impl class mask.
+         */
+        if ((genFileType & IMPL_CLASS_MASK) != 0) {
+            generatedTempFiles |= ATTRIBUTES_MASK;
+            generatedTempFiles |= GETTER_FOR_CLASS_MASK;
+            generatedTempFiles |= CONSTRUCTOR_IMPL_MASK;
+            generatedTempFiles |= HASH_CODE_IMPL_MASK;
+            generatedTempFiles |= EQUALS_IMPL_MASK;
+            generatedTempFiles |= TO_STRING_IMPL_MASK;
+        }
+
+        if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) {
+            setAttributesTempFileHandle(getTemporaryFileHandle(ATTRIBUTE_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) {
+            setGetterInterfaceTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) {
+            setSetterInterfaceTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) {
+            setGetterImplTempFileHandle(getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) {
+            setSetterImplTempFileHandle(getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) {
+            setConstructorImplTempFileHandle(getTemporaryFileHandle(CONSTRUCTOR_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) {
+            setHashCodeImplTempFileHandle(getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) {
+            setEqualsImplTempFileHandle(getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME));
+        }
+        if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) {
+            setToStringImplTempFileHandle(getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME));
+        }
+
+    }
+
+    /**
+     * Returns attribute's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getAttributesTempFileHandle() {
+
+        return attributesTempFileHandle;
+    }
+
+    /**
+     * Sets attribute's temporary file handle.
+     *
+     * @param attributeForClass file handle for attribute
+     */
+    public void setAttributesTempFileHandle(File attributeForClass) {
+
+        attributesTempFileHandle = attributeForClass;
+    }
+
+    /**
+     * Returns getter methods's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getGetterInterfaceTempFileHandle() {
+
+        return getterInterfaceTempFileHandle;
+    }
+
+    /**
+     * Sets to getter method's temporary file handle.
+     *
+     * @param getterForInterface file handle for to getter method
+     */
+    public void setGetterInterfaceTempFileHandle(File getterForInterface) {
+
+        getterInterfaceTempFileHandle = getterForInterface;
+    }
+
+    /**
+     * Returns getter method's impl's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getGetterImplTempFileHandle() {
+
+        return getterImplTempFileHandle;
+    }
+
+    /**
+     * Sets to getter method's impl's temporary file handle.
+     *
+     * @param getterImpl file handle for to getter method's impl
+     */
+    public void setGetterImplTempFileHandle(File getterImpl) {
+
+        getterImplTempFileHandle = getterImpl;
+    }
+
+    /**
+     * Returns setter method's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getSetterInterfaceTempFileHandle() {
+
+        return setterInterfaceTempFileHandle;
+    }
+
+    /**
+     * Sets to setter method's temporary file handle.
+     *
+     * @param setterForInterface file handle for to setter method
+     */
+    public void setSetterInterfaceTempFileHandle(File setterForInterface) {
+
+        setterInterfaceTempFileHandle = setterForInterface;
+    }
+
+    /**
+     * Returns setter method's impl's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getSetterImplTempFileHandle() {
+
+        return setterImplTempFileHandle;
+    }
+
+    /**
+     * Sets to setter method's impl's temporary file handle.
+     *
+     * @param setterImpl file handle for to setter method's implementation class
+     */
+    public void setSetterImplTempFileHandle(File setterImpl) {
+
+        setterImplTempFileHandle = setterImpl;
+    }
+
+    /**
+     * Returns constructor's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getConstructorImplTempFileHandle() {
+
+        return constructorImplTempFileHandle;
+    }
+
+    /**
+     * Sets to constructor's temporary file handle.
+     *
+     * @param constructor file handle for to constructor
+     */
+    public void setConstructorImplTempFileHandle(File constructor) {
+
+        constructorImplTempFileHandle = constructor;
+    }
+
+    /**
+     * Returns hash code method's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getHashCodeImplTempFileHandle() {
+
+        return hashCodeImplTempFileHandle;
+    }
+
+    /**
+     * Sets hash code method's temporary file handle.
+     *
+     * @param hashCodeMethod file handle for hash code method
+     */
+    public void setHashCodeImplTempFileHandle(File hashCodeMethod) {
+
+        hashCodeImplTempFileHandle = hashCodeMethod;
+    }
+
+    /**
+     * Returns equals mehtod's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getEqualsImplTempFileHandle() {
+
+        return equalsImplTempFileHandle;
+    }
+
+    /**
+     * Sets equals method's temporary file handle.
+     *
+     * @param equalsMethod file handle for to equals method
+     */
+    public void setEqualsImplTempFileHandle(File equalsMethod) {
+
+        equalsImplTempFileHandle = equalsMethod;
+    }
+
+    /**
+     * Returns to string method's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getToStringImplTempFileHandle() {
+
+        return toStringImplTempFileHandle;
+    }
+
+    /**
+     * Sets to string method's temporary file handle.
+     *
+     * @param toStringMethod file handle for to string method
+     */
+    public void setToStringImplTempFileHandle(File toStringMethod) {
+
+        toStringImplTempFileHandle = toStringMethod;
+    }
+
+    /**
+     * Adds attribute for class.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addAttribute(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getAttributesTempFileHandle(), parseAttribute(attr) + UtilConstants.FOUR_SPACE_INDENTATION);
+    }
+
+    /**
+     * Adds getter for interface.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addGetterForInterface(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getGetterInterfaceTempFileHandle(),
+                getGetterString(attr) + UtilConstants.NEW_LINE);
+    }
+
+    /**
+     * Adds getter method's impl for class.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addGetterImpl(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getGetterImplTempFileHandle(),
+                getOverRideString() + getGetterForClass(attr) + UtilConstants.NEW_LINE);
+    }
+
+    /**
+     * Adds setter for interface.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addSetterForInterface(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getSetterInterfaceTempFileHandle(),
+                getSetterString(attr, generatedJavaClassName) + UtilConstants.NEW_LINE);
+    }
+
+    /**
+     * Adds setter's implementation for class.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addSetterImpl(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getSetterImplTempFileHandle(),
+                getOverRideString() + getSetterForClass(attr, generatedJavaClassName) + UtilConstants.NEW_LINE);
+    }
+
+    /**
+     * Adds build method for interface.
+     *
+     * @return build method for interface
+     * @throws IOException when fails to append to temporary file
+     */
+    public String addBuildMethodForInterface() throws IOException {
+
+        return parseBuilderInterfaceBuildMethodString(generatedJavaClassName);
+    }
+
+    /**
+     * Adds build method's implementation for class.
+     *
+     * @return build method implementation for class
+     * @throws IOException when fails to append to temporary file
+     */
+    public String addBuildMethodImpl() throws IOException {
+
+        return getBuildString(generatedJavaClassName) + UtilConstants.NEW_LINE;
+    }
+
+    /**
+     * Adds constructor for class.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addConstructor(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getConstructorImplTempFileHandle(), getConstructor(generatedJavaClassName, attr));
+    }
+
+    /**
+     * Adds default constructor for class.
+     *
+     * @return default constructor for class
+     * @throws IOException when fails to append to file
+     */
+    public String addDefaultConstructor() throws IOException {
+
+        return UtilConstants.NEW_LINE + getDefaultConstructorString(generatedJavaClassName + UtilConstants.BUILDER,
+                UtilConstants.PUBLIC);
+    }
+
+    /**
+     * Adds hash code method for class.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addHashCodeMethod(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getHashCodeImplTempFileHandle(), getHashCodeMethod(attr) + UtilConstants.NEW_LINE);
+    }
+
+    /**
+     * Adds equals method for class.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addEqualsMethod(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getEqualsImplTempFileHandle(), getEqualsMethod(attr) + UtilConstants.NEW_LINE);
+    }
+
+    /**
+     * Adds ToString method for class.
+     *
+     * @param attr attribute info
+     * @throws IOException when fails to append to temporary file
+     */
+    public void addToStringMethod(JavaAttributeInfo attr) throws IOException {
+
+        appendToFile(getToStringImplTempFileHandle(), getToStringMethod(attr) + UtilConstants.NEW_LINE);
+    }
+
+    /**
+     * Returns a temporary file handle for the specific file type.
+     *
+     * @param fileName file name
+     * @return temporary file handle
+     * @throws IOException when fails to create new file handle
+     */
+    private File getTemporaryFileHandle(String fileName) throws IOException {
+
+        String path = getTempDirPath();
+        File dir = new File(path);
+        if (!dir.exists()) {
+            dir.mkdirs();
+        }
+
+        File file = new File(path + fileName + TEMP_FILE_EXTENSION);
+        if (!file.exists()) {
+            file.createNewFile();
+        } else {
+            file.delete();
+            file.createNewFile();
+        }
+        return file;
+    }
+
+    /**
+     * Returns data from the temporary files.
+     *
+     * @param file temporary file handle
+     * @return stored data from temporary files
+     * @throws IOException when failed to get data from the given file
+     */
+    public String getTemporaryDataFromFileHandle(File file) throws IOException {
+
+        String path = getTempDirPath();
+        if (new File(path + file.getName()).exists()) {
+            return FileSystemUtil.readAppendFile(path + file.getName(), UtilConstants.EMPTY_STRING);
+        } else {
+            throw new IOException("Unable to get data from the given "
+                    + file.getName() + " file for "
+                    + generatedJavaClassName + UtilConstants.PERIOD);
+        }
+    }
+
+    /**
+     * Returns temporary directory path.
+     *
+     * @return directory path
+     */
+    private String getTempDirPath() {
+
+        return absoluteDirPath.replace(UtilConstants.PERIOD, UtilConstants.SLASH)
+                + File.separator + generatedJavaClassName + TEMP_FOLDER_NAME_SUFIX + File.separator;
+    }
+
+    /**
+     * Parse attribute to get the attribute string.
+     *
+     * @param attr attribute info
+     * @return attribute string
+     */
+    private String parseAttribute(JavaAttributeInfo attr) {
+
+        /*
+         * TODO: check if this utility needs to be called or move to the caller
+         */
+        String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        if (attr.isQualifiedName()) {
+            return getJavaAttributeDefination(attr.getImportInfo().getPkgInfo(), attr.getImportInfo().getClassInfo(),
+                    attributeName, attr.isListAttr());
+        } else {
+            return getJavaAttributeDefination(null, attr.getImportInfo().getClassInfo(), attributeName,
+                    attr.isListAttr());
+        }
+    }
+
+    /**
+     * Append content to temporary file.
+     *
+     * @param file temporary file
+     * @param data data to be appended
+     * @throws IOException when fails to append to file
+     */
+    private void appendToFile(File file, String data) throws IOException {
+
+        try {
+            JavaFileGenerator.insert(file, data);
+        } catch (IOException ex) {
+            throw new IOException("failed to write in temp file.");
+        }
+    }
+
+    /**
+     * Adds current node info as and attribute to the parent generated file.
+     *
+     * @param curNode current node which needs to be added as an attribute in
+     *            the parent generated code
+     * @param isList is list construct
+     * @throws IOException IO operation exception
+     */
+    public void addCurNodeInfoInParentTempFile(YangNode curNode,
+            boolean isList) throws IOException {
+
+        YangNode parent = getParentNodeInGenCode(curNode);
+        if (!(parent instanceof JavaCodeGenerator)) {
+            throw new RuntimeException("missing parent node to contain current node info in generated file");
+        }
+        JavaAttributeInfo javaAttributeInfo = getCurNodeAsAttributeInParent(curNode,
+                parent, isList);
+
+        if (!(parent instanceof HasTempJavaCodeFragmentFiles)) {
+            throw new RuntimeException("missing parent temp file handle");
+        }
+        ((HasTempJavaCodeFragmentFiles) parent)
+                .getTempJavaCodeFragmentFiles()
+                .addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo);
+    }
+
+    /**
+     * Adds leaf attributes in generated files.
+     *
+     * @param listOfLeaves list of YANG leaf
+     * @param curNode current data model node
+     * @throws IOException IO operation fail
+     */
+    private void addLeavesInfoToTempFiles(List<YangLeaf> listOfLeaves,
+            YangNode curNode) throws IOException {
+
+        if (listOfLeaves != null) {
+            for (YangLeaf leaf : listOfLeaves) {
+                JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfLeaf(curNode,
+                        leaf.getDataType(),
+                        leaf.getLeafName(), false);
+                addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo);
+            }
+        }
+    }
+
+    /**
+     * Adds leaf list's attributes in generated files.
+     *
+     * @param listOfLeafList list of YANG leaves
+     * @param curNode cached file handle
+     * @throws IOException IO operation fail
+     */
+    private void addLeafListInfoToTempFiles(List<YangLeafList> listOfLeafList,
+            YangNode curNode) throws IOException {
+
+        if (listOfLeafList != null) {
+
+            /*
+             * Check if the attribute is of type list, then the java.lang.list
+             * needs to be imported.
+             */
+            if (listOfLeafList.size() != 0) {
+                if (!(curNode instanceof HasJavaImportData)) {
+                    throw new RuntimeException("missing import info in current data model node");
+
+                }
+                ((HasJavaImportData) curNode).getJavaImportData()
+                        .setIfListImported(true);
+
+            }
+
+            for (YangLeafList leafList : listOfLeafList) {
+                JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfLeaf(
+                        curNode, leafList.getDataType(), leafList.getLeafName(),
+                        true);
+                addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo);
+            }
+        }
+    }
+
+    /**
+     * Add all the leaves in the current data model node as part of the
+     * generated temporary file.
+     *
+     * @param curNode java file info of the generated file
+     * @throws IOException IO operation fail
+     */
+    public void addCurNodeLeavesInfoToTempFiles(YangNode curNode) throws IOException {
+
+        if (curNode instanceof YangLeavesHolder) {
+            YangLeavesHolder leavesHolder = (YangLeavesHolder) curNode;
+            addLeavesInfoToTempFiles(leavesHolder.getListOfLeaf(), curNode);
+            addLeafListInfoToTempFiles(leavesHolder.getListOfLeafList(), curNode);
+        }
+    }
+
+    /**
+     * Add the new attribute info to the target generated temporary files.
+     *
+     * @param newAttrInfo the attribute info that needs to be added to temporary
+     *            files
+     * @throws IOException IO operation fail
+     */
+    void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo newAttrInfo)
+            throws IOException {
+
+        if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) {
+            addAttribute(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) {
+            addGetterForInterface(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) {
+            addSetterForInterface(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) {
+            addGetterImpl(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) {
+            addSetterImpl(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) {
+            addConstructor(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) {
+            addHashCodeMethod(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) {
+            addEqualsMethod(newAttrInfo);
+        }
+
+        if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) {
+            addToStringMethod(newAttrInfo);
+        }
+        return;
+    }
+
+    /**
+     * Removes all temporary file handles.
+     *
+     * @throws IOException when failed to delete the temporary files
+     */
+    public void close() throws IOException {
+
+        closeFile(GETTER_METHOD_FILE_NAME);
+        getTemporaryFileHandle(GETTER_METHOD_FILE_NAME).delete();
+
+        closeFile(GETTER_METHOD_IMPL_FILE_NAME);
+        getTemporaryFileHandle(GETTER_METHOD_IMPL_FILE_NAME).delete();
+
+        closeFile(SETTER_METHOD_FILE_NAME);
+        getTemporaryFileHandle(SETTER_METHOD_FILE_NAME).delete();
+
+        closeFile(SETTER_METHOD_IMPL_FILE_NAME);
+        getTemporaryFileHandle(SETTER_METHOD_IMPL_FILE_NAME).delete();
+
+        closeFile(CONSTRUCTOR_FILE_NAME);
+        getTemporaryFileHandle(CONSTRUCTOR_FILE_NAME).delete();
+
+        closeFile(ATTRIBUTE_FILE_NAME);
+        getTemporaryFileHandle(ATTRIBUTE_FILE_NAME).delete();
+
+        closeFile(HASH_CODE_METHOD_FILE_NAME);
+        getTemporaryFileHandle(HASH_CODE_METHOD_FILE_NAME).delete();
+
+        closeFile(TO_STRING_METHOD_FILE_NAME);
+        getTemporaryFileHandle(TO_STRING_METHOD_FILE_NAME).delete();
+
+        closeFile(EQUALS_METHOD_FILE_NAME);
+        getTemporaryFileHandle(EQUALS_METHOD_FILE_NAME).delete();
+
+    }
+
+    /**
+     * Closes the file handle for temporary file.
+     *
+     * @param fileName temporary file's name
+     * @throws IOException when failed to close the file handle
+     */
+    private void closeFile(String fileName) throws IOException {
+
+        FileSystemUtil.updateFileHandle(new File(fileName), null, true);
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
new file mode 100644
index 0000000..329d934
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaAugment.java
@@ -0,0 +1,181 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangAugment;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Augment information extended to support java code generation.
+ */
+public class YangJavaAugment extends YangAugment
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaAugment() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+
+        if (tempFileHandle == null) {
+            throw new RuntimeException("missing temp file hand for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * augment info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+
+        getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     */
+    @Override
+    public void generateCodeExit() {
+        // TODO Auto-generated method stub
+
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
new file mode 100644
index 0000000..739119e
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaCase.java
@@ -0,0 +1,181 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangCase;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Case information extended to support java code generation.
+ */
+public class YangJavaCase extends YangCase
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaCase() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+
+        if (tempFileHandle == null) {
+            throw new RuntimeException("missing temp file hand for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * case info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+
+        getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     */
+    @Override
+    public void generateCodeExit() {
+        // TODO Auto-generated method stub
+
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
new file mode 100644
index 0000000..50c04ed
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaChoice.java
@@ -0,0 +1,181 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangChoice;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Choice information extended to support java code generation.
+ */
+public class YangJavaChoice extends YangChoice
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaChoice() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+
+        if (tempFileHandle == null) {
+            throw new RuntimeException("missing temp file hand for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * case info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        //        TODO:getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+
+        getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     */
+    @Override
+    public void generateCodeExit() {
+        // TODO Auto-generated method stub
+
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
new file mode 100644
index 0000000..c1fb5ea
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaContainer.java
@@ -0,0 +1,187 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.GenerateJavaCodeExitBuilder.generateJavaFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Container information extended to support java code generation.
+ */
+public class YangJavaContainer extends YangContainer
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaContainer() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+
+        if (tempFileHandle == null) {
+            throw new RuntimeException("Missing temp file handle for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * container info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+        createPackage(absloutePath, getName());
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+
+        getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     *
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeExit() throws IOException {
+
+        generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
+        getTempJavaCodeFragmentFiles().close();
+    }
+
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
new file mode 100644
index 0000000..1b1b818
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaGrouping.java
@@ -0,0 +1,181 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Grouping information extended to support java code generation.
+ */
+public class YangJavaGrouping extends YangGrouping
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaGrouping() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+
+        if (tempFileHandle == null) {
+            throw new RuntimeException("missing temp file hand for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * container info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+
+        getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, false);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     */
+    @Override
+    public void generateCodeExit() {
+        // TODO Auto-generated method stub
+
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
new file mode 100644
index 0000000..9469f69
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaList.java
@@ -0,0 +1,186 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.GenerateJavaCodeExitBuilder.generateJavaFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * YANG List information extended to support java code generation.
+ */
+public class YangJavaList extends YangList
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaList() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+
+        if (tempFileHandle == null) {
+            throw new RuntimeException("missing temp file hand for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * container info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+        createPackage(absloutePath, getName());
+
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+
+        getTempJavaCodeFragmentFiles().addCurNodeInfoInParentTempFile(this, true);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     *
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeExit() throws IOException {
+
+        generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
+        getTempJavaCodeFragmentFiles().close();
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
new file mode 100644
index 0000000..69e3ffa
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
@@ -0,0 +1,181 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.GenerateJavaCodeExitBuilder.generateJavaFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
+import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Module information extended to support java code generation.
+ */
+public class YangJavaModule extends YangModule
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Create a YANG node of module type.
+     */
+    public YangJavaModule() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+
+        if (tempFileHandle == null) {
+            throw new RuntimeException("missing temp file hand for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Generates java code for module.
+     *
+     * @param baseCodeGenDir code generation directory
+     * @throws IOException when fails to generate the source files
+     */
+    @Override
+    public void generateCodeEntry(String baseCodeGenDir) throws IOException {
+
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getRootPackage(getVersion(), getNameSpace().getUri(),
+                getRevision().getRevDate()));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(baseCodeGenDir);
+
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+
+        createPackage(absloutePath, getName());
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+    }
+
+    @Override
+    public void generateCodeExit() throws IOException {
+
+        generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
+        getTempJavaCodeFragmentFiles().close();
+        return;
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
new file mode 100644
index 0000000..6047206
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
@@ -0,0 +1,187 @@
+/*
+ * 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.javamodel;
+
+import java.io.IOException;
+
+import org.onosproject.yangutils.datamodel.YangBelongsTo;
+import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getAbsolutePackagePath;
+
+/**
+ * Sub module information extended to support java code generation.
+ */
+public class YangJavaSubModule extends YangSubModule
+        implements JavaCodeGenerator, HasJavaFileInfo,
+        HasJavaImportData, HasTempJavaCodeFragmentFiles {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * File handle to maintain temporary java code fragments as per the code
+     * snippet types.
+     */
+    private TempJavaCodeFragmentFiles tempFileHandle;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaSubModule() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Get the temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    @Override
+    public TempJavaCodeFragmentFiles getTempJavaCodeFragmentFiles() {
+        if (tempFileHandle == null) {
+            throw new RuntimeException("missing temp file hand for current node "
+                    + getJavaFileInfo().getJavaName());
+        }
+        return tempFileHandle;
+    }
+
+    /**
+     * Set temporary file handle.
+     *
+     * @param fileHandle temporary file handle
+     */
+    @Override
+    public void setTempJavaCodeFragmentFiles(TempJavaCodeFragmentFiles fileHandle) {
+        tempFileHandle = fileHandle;
+    }
+
+    /**
+     * Get the name space of the module to which the sub module belongs to.
+     *
+     * @param belongsToInfo Information of the module to which the sub module
+     *            belongs
+     * @return the name space string of the module.
+     */
+    private String getNameSpaceFromModule(YangBelongsTo belongsToInfo) {
+        // TODO Auto-generated method stub
+        return "";
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * container info.
+     *
+     * @param codeGenDir code generation directory
+     * @throws IOException IO operation fail
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) throws IOException {
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getRootPackage(getVersion(),
+                getNameSpaceFromModule(getBelongsTo()),
+                getRevision().getRevDate()));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+
+        String absloutePath = getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
+                getJavaFileInfo().getPackageFilePath());
+
+        setTempJavaCodeFragmentFiles(new TempJavaCodeFragmentFiles(
+                getJavaFileInfo().getGeneratedFileTypes(), absloutePath,
+                getJavaFileInfo().getJavaName()));
+
+        getTempJavaCodeFragmentFiles().addCurNodeLeavesInfoToTempFiles(this);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     */
+    @Override
+    public void generateCodeExit() {
+        // TODO Auto-generated method stub
+
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
new file mode 100644
index 0000000..50ecc2d
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
@@ -0,0 +1,127 @@
+/*
+ * 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.javamodel;
+
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+
+/**
+ * Type define information extended to support java code generation.
+ */
+public class YangJavaTypeDef extends YangTypeDef
+        implements JavaCodeGenerator, HasJavaFileInfo, HasJavaImportData {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaTypeDef() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * container info.
+     *
+     * @param codeGenDir code generation directory
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) {
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+        // TODO: generate type define temporary files
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     */
+    @Override
+    public void generateCodeExit() {
+        // TODO Auto-generated method stub
+
+    }
+
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUses.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUses.java
new file mode 100644
index 0000000..cc29a74
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUses.java
@@ -0,0 +1,126 @@
+/*
+ * 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.javamodel;
+
+import org.onosproject.yangutils.datamodel.YangUses;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCurNodePackage;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getPackageDirPathFromJavaJPackage;
+
+/**
+ * Uses information extended to support java code generation.
+ */
+public class YangJavaUses extends YangUses implements JavaCodeGenerator, HasJavaFileInfo, HasJavaImportData {
+
+    /**
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Contains information of the imports to be inserted in the java file
+     * generated.
+     */
+    private JavaImportData javaImportData;
+
+    /**
+     * Default constructor.
+     */
+    public YangJavaUses() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
+        setJavaImportData(new JavaImportData());
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+    }
+
+    /**
+     * Get the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+        if (javaFileInfo == null) {
+            throw new RuntimeException("Missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Set the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+        javaFileInfo = javaInfo;
+    }
+
+    /**
+     * Get the data of java imports to be included in generated file.
+     *
+     * @return data of java imports to be included in generated file
+     */
+    @Override
+    public JavaImportData getJavaImportData() {
+        return javaImportData;
+    }
+
+    /**
+     * Set the data of java imports to be included in generated file.
+     *
+     * @param javaImportData data of java imports to be included in generated
+     *            file
+     */
+    @Override
+    public void setJavaImportData(JavaImportData javaImportData) {
+        this.javaImportData = javaImportData;
+    }
+
+    /**
+     * Prepare the information for java code generation corresponding to YANG
+     * container info.
+     *
+     * @param codeGenDir code generation directory
+     */
+    @Override
+    public void generateCodeEntry(String codeGenDir) {
+        getJavaFileInfo().setJavaName(getCaptialCase(getCamelCase(getName())));
+        getJavaFileInfo().setPackage(getCurNodePackage(this));
+        getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(getJavaFileInfo().getPackage()));
+        getJavaFileInfo().setBaseCodeGenPath(codeGenDir);
+        //TODO:addCurNodeLeavesInfoToTempFiles(this);
+        //TODO:addCurNodeInfoInParentTempFile(this, false);
+    }
+
+    /**
+     * Create a java file using the YANG grouping info.
+     */
+    @Override
+    public void generateCodeExit() {
+        // TODO Auto-generated method stub
+
+    }
+}
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/package-info.java b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/package-info.java
new file mode 100644
index 0000000..d4fa4b9
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Maintains application's schema mapped to java classes / interfaces.
+ */
+package org.onosproject.yangutils.translator.tojava.javamodel;
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
index 138b7d4..97b4758 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/AttributesJavaDataType.java
@@ -16,8 +16,12 @@
 
 package org.onosproject.yangutils.translator.tojava.utils;
 
+import java.util.Set;
+import java.util.TreeSet;
+
 import org.onosproject.yangutils.datamodel.YangDataTypes;
 import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
 import org.onosproject.yangutils.utils.UtilConstants;
 
 /**
@@ -25,6 +29,8 @@
  */
 public final class AttributesJavaDataType {
 
+    private static Set<JavaQualifiedTypeInfo> importInfo = new TreeSet<>();
+
     /**
      * Default constructor.
      */
@@ -32,6 +38,24 @@
     }
 
     /**
+     * Returns import info.
+     *
+     * @return import info
+     */
+    public static Set<JavaQualifiedTypeInfo> getImportInfo() {
+        return importInfo;
+    }
+
+    /**
+     * Adds import info to the import info set.
+     *
+     * @param importData import info
+     */
+    public static void addImportInfo(JavaQualifiedTypeInfo importData) {
+        getImportInfo().add(importData);
+    }
+
+    /**
      * Returns java type.
      *
      * @param yangType YANG type
@@ -134,7 +158,8 @@
             } else if (type.equals(YangDataTypes.INSTANCE_IDENTIFIER)) {
                 //TODO:INSTANCE_IDENTIFIER
             } else if (type.equals(YangDataTypes.DERIVED)) {
-                //TODO:DERIVED
+                return JavaIdentifierSyntax
+                        .getCaptialCase(JavaIdentifierSyntax.getCamelCase(yangType.getDataTypeName()));
             }
         } else {
             if (type.equals(YangDataTypes.UINT64)) {
@@ -160,7 +185,8 @@
             } else if (type.equals(YangDataTypes.INSTANCE_IDENTIFIER)) {
                 //TODO:INSTANCE_IDENTIFIER
             } else if (type.equals(YangDataTypes.DERIVED)) {
-                //TODO:DERIVED
+                return JavaIdentifierSyntax
+                        .getCaptialCase(JavaIdentifierSyntax.getCamelCase(yangType.getDataTypeName()));
             }
         }
         return null;
@@ -171,9 +197,10 @@
      *
      * @param yangType YANG type
      * @param isListAttr if the attribute is of list type
+     * @param classInfo java import class info
      * @return java import package
      */
-    public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr) {
+    public static String getJavaImportPackage(YangType<?> yangType, boolean isListAttr, String classInfo) {
         YangDataTypes type = yangType.getDataType();
 
         if (isListAttr) {
@@ -208,7 +235,11 @@
             } else if (type.equals(YangDataTypes.INSTANCE_IDENTIFIER)) {
                 //TODO:INSTANCE_IDENTIFIER
             } else if (type.equals(YangDataTypes.DERIVED)) {
-                //TODO:DERIVED
+                for (JavaQualifiedTypeInfo imports : getImportInfo()) {
+                    if (imports.getClassInfo().equals(classInfo)) {
+                        return imports.getPkgInfo();
+                    }
+                }
             }
         } else {
 
@@ -235,7 +266,11 @@
             } else if (type.equals(YangDataTypes.INSTANCE_IDENTIFIER)) {
                 //TODO:INSTANCE_IDENTIFIER
             } else if (type.equals(YangDataTypes.DERIVED)) {
-                //TODO:DERIVED
+                for (JavaQualifiedTypeInfo imports : getImportInfo()) {
+                    if (imports.getClassInfo().equals(classInfo)) {
+                        return imports.getPkgInfo();
+                    }
+                }
             }
         }
         return null;
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
index c0f4a15..6f3b3bb 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.yangutils.translator.tojava.utils;
 
-import org.onosproject.yangutils.translator.GeneratedFileType;
+import org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType;
 import org.onosproject.yangutils.utils.UtilConstants;
 
 /**
@@ -44,19 +44,19 @@
          * based on the file type and the YANG name of the file, generate the
          * class / interface definition start.
          */
-        if ((genFileTypes & GeneratedFileType.INTERFACE_MASK) != 0) {
+        if ((genFileTypes & GeneratedJavaFileType.INTERFACE_MASK) != 0) {
 
             return getInterfaceDefinition(yangName);
-        } else if ((genFileTypes & GeneratedFileType.BUILDER_CLASS_MASK) != 0) {
+        } else if ((genFileTypes & GeneratedJavaFileType.BUILDER_CLASS_MASK) != 0) {
 
             return getBuilderClassDefinition(yangName);
-        } else if ((genFileTypes & GeneratedFileType.IMPL_CLASS_MASK) != 0) {
+        } else if ((genFileTypes & GeneratedJavaFileType.IMPL_CLASS_MASK) != 0) {
 
             return getImplClassDefinition(yangName);
-        } else if ((genFileTypes & GeneratedFileType.BUILDER_INTERFACE_MASK) != 0) {
+        } else if ((genFileTypes & GeneratedJavaFileType.BUILDER_INTERFACE_MASK) != 0) {
 
             return getBuilderInterfaceDefinition(yangName);
-        } else if ((genFileTypes & GeneratedFileType.GENERATE_TYPEDEF_CLASS) != 0) {
+        } else if ((genFileTypes & GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS) != 0) {
 
             return getTypeDefClassDefinition(yangName);
         }
@@ -112,7 +112,7 @@
         return UtilConstants.PUBLIC + UtilConstants.SPACE + UtilConstants.FINAL + UtilConstants.SPACE
                 + UtilConstants.CLASS + UtilConstants.SPACE + yangName + UtilConstants.IMPL + UtilConstants.SPACE
                 + UtilConstants.IMPLEMENTS + UtilConstants.SPACE + yangName + UtilConstants.SPACE
-                + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.NEW_LINE;
+                + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE;
     }
 
     /**
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/GenerateJavaCodeExitBuilder.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/GenerateJavaCodeExitBuilder.java
new file mode 100644
index 0000000..4acb1e3
--- /dev/null
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/GenerateJavaCodeExitBuilder.java
@@ -0,0 +1,232 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasJavaImportData;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaImportData;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
+import org.onosproject.yangutils.utils.UtilConstants;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.appendFileContents;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.clean;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.closeFileHandles;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderClassFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateBuilderInterfaceFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateImplClassFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateInterfaceFile;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.getFileObject;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.insert;
+
+/**
+ * Provides generate java code exit.
+ */
+public final class GenerateJavaCodeExitBuilder {
+
+    private static final String JAVA_FILE_EXTENSION = ".java";
+
+    /**
+     * Default constructor.
+     */
+    private GenerateJavaCodeExitBuilder() {
+    }
+
+    /**
+     * Sets import for hash and equals method.
+     *
+     * @return import string for implementing hash and equals
+     */
+    private static String setImportForHashAndEquals() {
+
+        return UtilConstants.IMPORT + UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG + UtilConstants.PERIOD
+                + UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_CLASS;
+    }
+
+    /**
+     * Sets import for to string method.
+     *
+     * @return import string for implementing to string
+     */
+    private static String setImportForToString() {
+
+        return UtilConstants.IMPORT + UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_PKG + UtilConstants.PERIOD
+                + UtilConstants.GOOGLE_MORE_OBJECT_IMPORT_CLASS;
+    }
+
+    /**
+     * Sets import for to list.
+     *
+     * @return import string for list collection
+     */
+    private static String setImportForList() {
+
+        return UtilConstants.IMPORT + UtilConstants.COLLECTION_IMPORTS + UtilConstants.PERIOD
+                + UtilConstants.LIST + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE;
+    }
+
+    /**
+     * Construct java code exit.
+     *
+     * @param fileType generated file type
+     * @param curNode current YANG node
+     * @throws IOException when fails to generate java files
+     */
+    public static void generateJavaFile(int fileType, YangNode curNode) throws IOException {
+
+        JavaFileInfo javaFileInfo = ((HasJavaFileInfo) curNode).getJavaFileInfo();
+        String className = JavaIdentifierSyntax.getCaptialCase(javaFileInfo.getJavaName());
+        String pkg = javaFileInfo.getPackageFilePath();
+        List<String> imports = getImports(((HasJavaImportData) curNode).getJavaImportData());
+
+        /**
+         * Start generation of files.
+         */
+        if ((fileType & INTERFACE_MASK) != 0 | (fileType & BUILDER_INTERFACE_MASK) != 0
+                | fileType == GENERATE_INTERFACE_WITH_BUILDER) {
+
+            /**
+             * Create interface file.
+             */
+            String interfaceFileName = className;
+            File interfaceFile = getFileObject(pkg, interfaceFileName, JAVA_FILE_EXTENSION, javaFileInfo);
+            interfaceFile = generateInterfaceFile(interfaceFile, imports, curNode);
+            /**
+             * Create temp builder interface file.
+             */
+            String builderInterfaceFileName = className
+                    + UtilConstants.BUILDER + UtilConstants.INTERFACE;
+            File builderInterfaceFile = getFileObject(pkg, builderInterfaceFileName, JAVA_FILE_EXTENSION, javaFileInfo);
+            builderInterfaceFile = generateBuilderInterfaceFile(builderInterfaceFile, curNode);
+            /**
+             * Append builder interface file to interface file and close it.
+             */
+            appendFileContents(builderInterfaceFile, interfaceFile);
+            insert(interfaceFile, JavaCodeSnippetGen.getJavaClassDefClose());
+            /**
+             * Close file handle for interface files.
+             */
+            closeFileHandles(builderInterfaceFile);
+            closeFileHandles(interfaceFile);
+
+            /**
+             * Remove temp files.
+             */
+            clean(builderInterfaceFile);
+        }
+
+        imports.add(setImportForHashAndEquals());
+        imports.add(setImportForToString());
+        java.util.Collections.sort(imports);
+
+        if ((fileType & BUILDER_CLASS_MASK) != 0 | (fileType & IMPL_CLASS_MASK) != 0
+                | fileType == GENERATE_INTERFACE_WITH_BUILDER) {
+
+            /**
+             * Create builder class file.
+             */
+            String builderFileName = className
+                    + UtilConstants.BUILDER;
+            File builderFile = getFileObject(pkg, builderFileName, JAVA_FILE_EXTENSION, javaFileInfo);
+            builderFile = generateBuilderClassFile(builderFile, imports, curNode);
+            /**
+             * Create temp impl class file.
+             */
+
+            String implFileName = className + UtilConstants.IMPL;
+            File implTempFile = getFileObject(pkg, implFileName, JAVA_FILE_EXTENSION, javaFileInfo);
+            implTempFile = generateImplClassFile(implTempFile, curNode);
+            /**
+             * Append impl class to builder class and close it.
+             */
+            appendFileContents(implTempFile, builderFile);
+            insert(builderFile, JavaCodeSnippetGen.getJavaClassDefClose());
+
+            /**
+             * Close file handle for classes files.
+             */
+            closeFileHandles(implTempFile);
+            closeFileHandles(builderFile);
+
+            /**
+             * Remove temp files.
+             */
+            clean(implTempFile);
+        }
+
+        /**
+         * if ((fileType & GENERATE_TYPEDEF_CLASS) != 0) {
+         *
+         * /** Create builder class file. //
+         */
+        //String typeDefFileName = className;
+        //File typeDefFile = JavaFileGenerator.getFileObject(path, typeDefFileName, JAVA_FILE_EXTENSION,
+        //      ((HasJavaFileInfo) curNode).getJavaFileInfo());
+        //typeDefFile = JavaFileGenerator.generateTypeDefClassFile(typeDefFile, className, imports,
+        //        path.replace('/', '.'), attrList, ((HasJavaFileInfo) curNode).getJavaFileInfo());
+        // JavaFileGenerator.insert(typeDefFile, JavaCodeSnippetGen.getJavaClassDefClose());
+
+        //  /**
+        //     * Close file handle for classes files.
+        //       */
+        //        JavaFileGenerator.closeFileHandles(typeDefFile);
+        //      }
+        //
+    }
+
+    /**
+     * Returns import for class.
+     *
+     * @param javaImportData import data
+     * @return imports for class
+     */
+    private static List<String> getImports(JavaImportData javaImportData) {
+
+        String importString;
+        List<String> imports = new ArrayList<>();
+
+        for (JavaQualifiedTypeInfo importInfo : javaImportData.getImportSet()) {
+            importString = UtilConstants.IMPORT;
+            if (importInfo.getPkgInfo() != "" && importInfo.getClassInfo() != null
+                    && importInfo.getPkgInfo() != UtilConstants.JAVA_LANG) {
+                importString = importString + importInfo.getPkgInfo() + ".";
+                importString = importString + importInfo.getClassInfo() + UtilConstants.SEMI_COLAN
+                        + UtilConstants.NEW_LINE;
+
+                imports.add(importString);
+            }
+        }
+
+        if (javaImportData.getIfListImported()) {
+            imports.add(setImportForList());
+        }
+
+        java.util.Collections.sort(imports);
+        return imports;
+    }
+}
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;
     }
 
 }
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index 221f757..ab537c8 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -16,36 +16,55 @@
 
 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.datamodel.YangNode;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
 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.YangIoUtils;
-import org.slf4j.Logger;
+
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.BUILDER_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ATTRIBUTES_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.GETTER_FOR_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.HASH_CODE_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_CLASS_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.SETTER_FOR_INTERFACE_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.TO_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCaptialCase;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getBuildString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getConstructorStart;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getDefaultConstructorString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodClose;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getEqualsMethodOpen;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodClose;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getHashCodeMethodOpen;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodClose;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringMethodOpen;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.parseBuilderInterfaceBuildMethodString;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.partString;
 
 /**
  * Generates java file.
  */
 public final class JavaFileGenerator {
 
-    private static final Logger log = getLogger(JavaFileGenerator.class);
-
     /**
      * Default constructor.
      */
@@ -61,42 +80,37 @@
      * @param handle cached file handle
      * @return file object
      */
-    public static File getFileObject(String filePath, String fileName, String extension, CachedFileHandle handle) {
-        return new File(handle.getCodeGenFilePath() + filePath + File.separator + fileName + extension);
+    public static File getFileObject(String filePath, String fileName, String extension, JavaFileInfo handle) {
+
+        return new File(handle.getBaseCodeGenPath() + filePath + File.separator + fileName + extension);
     }
 
     /**
      * Returns generated interface file for current node.
      *
      * @param file file
-     * @param className class name
      * @param imports imports for the file
-     * @param attrList attribute info
-     * @param pkg generated file package
-     * @param handle cached file handle
+     * @param curNode current YANG node
      * @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, CachedFileHandle handle) throws IOException {
-        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
-        initiateFile(file, className, INTERFACE_MASK, imports, pkg);
+    public static File generateInterfaceFile(File file, List<String> imports, YangNode curNode) throws IOException {
 
-        if (!attrList.isEmpty()) {
-            List<String> methods = new ArrayList<>();
-            try {
-                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.");
-            }
+        JavaFileInfo javaFileInfo = ((HasJavaFileInfo) curNode).getJavaFileInfo();
 
-            /**
-             * Add getter methods to interface file.
-             */
-            for (String method : methods) {
-                appendMethod(file, method);
-            }
+        String className = getCaptialCase(javaFileInfo.getJavaName());
+        String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
+
+        initiateFile(file, className, INTERFACE_MASK, imports, path);
+
+        /**
+         * Add getter methods to interface file.
+         */
+        try {
+            appendMethod(file, getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, curNode));
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while interface file generation");
         }
         return file;
     }
@@ -105,39 +119,41 @@
      * Return generated builder interface file for current node.
      *
      * @param file file
-     * @param className class name
-     * @param pkg generated file package
-     * @param attrList attribute info
-     * @param handle cached file handle
+     * @param curNode current YANG node
      * @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, CachedFileHandle handle) throws IOException {
-        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
-        initiateFile(file, className, BUILDER_INTERFACE_MASK, null, pkg);
+    public static File generateBuilderInterfaceFile(File file, YangNode curNode) throws IOException {
+
+        JavaFileInfo javaFileInfo = ((HasJavaFileInfo) curNode).getJavaFileInfo();
+
+        String className = getCaptialCase(javaFileInfo.getJavaName());
+        String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
+
+        initiateFile(file, className, BUILDER_INTERFACE_MASK, null, path);
         List<String> methods = new ArrayList<>();
 
-        if (!attrList.isEmpty()) {
-
-            try {
-                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.");
-            }
+        try {
+            methods.add(UtilConstants.FOUR_SPACE_INDENTATION
+                    + getDataFromTempFileHandle(GETTER_FOR_INTERFACE_MASK, curNode));
+            methods.add(UtilConstants.NEW_LINE);
+            methods.add(UtilConstants.FOUR_SPACE_INDENTATION
+                    + getDataFromTempFileHandle(SETTER_FOR_INTERFACE_MASK, curNode));
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while builder interface file generation");
         }
+
         /**
          * Add build method to builder interface file.
          */
-        methods.add(MethodsGenerator.parseBuilderInterfaceBuildMethodString(className));
+        methods.add(parseBuilderInterfaceBuildMethodString(className));
 
         /**
          * Add getters and setters in builder interface.
          */
         for (String method : methods) {
-            appendMethod(file, UtilConstants.FOUR_SPACE_INDENTATION + method);
+            appendMethod(file, method);
         }
 
         insert(file, UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE);
@@ -148,61 +164,53 @@
      * Returns generated builder class file for current node.
      *
      * @param file file
-     * @param className class name
      * @param imports imports for the file
-     * @param pkg generated file package
-     * @param attrList attribute info
-     * @param handle cached file handle
+     * @param curNode current YANG node
      * @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, CachedFileHandle handle) throws IOException {
-        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
-        initiateFile(file, className, BUILDER_CLASS_MASK, imports, pkg);
+    public static File generateBuilderClassFile(File file, List<String> imports, YangNode curNode) throws IOException {
+
+        JavaFileInfo javaFileInfo = ((HasJavaFileInfo) curNode).getJavaFileInfo();
+
+        String className = getCaptialCase(javaFileInfo.getJavaName());
+        String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
+
+        initiateFile(file, className, BUILDER_CLASS_MASK, imports, path);
 
         List<String> methods = new ArrayList<>();
-        if (!attrList.isEmpty()) {
-            /**
-             * Add attribute strings.
-             */
-            List<String> attributes = new ArrayList<>();
-            try {
-                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.");
-            }
-            /**
-             * Add attributes to the file.
-             */
-            for (String attribute : attributes) {
-                insert(file, UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + attribute);
-            }
 
-            try {
-                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.");
-            }
-
+        /**
+         * Add attribute strings.
+         */
+        try {
+            insert(file, UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                    + getDataFromTempFileHandle(ATTRIBUTES_MASK, curNode));
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while builder class file generation");
         }
+
+        try {
+            methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, curNode));
+            methods.add(getDataFromTempFileHandle(SETTER_FOR_CLASS_MASK, curNode) + UtilConstants.NEW_LINE);
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while builder class file generation");
+        }
+
         /**
          * Add default constructor and build method impl.
          */
-        methods.add(
-                UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.JAVA_DOC_FIRST_LINE
-                        + MethodsGenerator.getDefaultConstructorString(className + UtilConstants.BUILDER,
-                                UtilConstants.PUBLIC));
-        methods.add(MethodsGenerator.getBuildString(className));
+        methods.add(getBuildString(className) + UtilConstants.NEW_LINE);
+        methods.add(UtilConstants.NEW_LINE
+                + getDefaultConstructorString(className + UtilConstants.BUILDER, UtilConstants.PUBLIC));
 
         /**
          * Add methods in builder class.
          */
         for (String method : methods) {
-            appendMethod(file, method + UtilConstants.NEW_LINE);
+            appendMethod(file, method);
         }
         return file;
     }
@@ -211,67 +219,59 @@
      * Returns generated impl class file for current node.
      *
      * @param file file
-     * @param className class name
-     * @param pkg generated file package
-     * @param attrList attribute's info
-     * @param handle cached file handle
+     * @param curNode current YANG node
      * @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,
-            CachedFileHandle handle)
-                    throws IOException {
-        String path = handle.getCodeGenFilePath() + pkg.replace(UtilConstants.PERIOD, UtilConstants.SLASH);
+    public static File generateImplClassFile(File file, YangNode curNode)
+            throws IOException {
+
+        JavaFileInfo javaFileInfo = ((HasJavaFileInfo) curNode).getJavaFileInfo();
+
+        String className = getCaptialCase(javaFileInfo.getJavaName());
+        String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
+
         initiateFile(file, className, IMPL_CLASS_MASK, null, path);
 
         List<String> methods = new ArrayList<>();
-        if (!attrList.isEmpty()) {
-            List<String> attributes = new ArrayList<>();
-            try {
-                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.");
-            }
 
-            /**
-             * Add attributes to the file.
-             */
-            for (String attribute : attributes) {
-                insert(file, UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + attribute);
-            }
+        /**
+         * Add attribute strings.
+         */
+        try {
+            insert(file, UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
+                    + getDataFromTempFileHandle(ATTRIBUTES_MASK, curNode));
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while impl class file generation");
+        }
 
-            try {
+        insert(file, UtilConstants.NEW_LINE);
+        try {
 
-                methods.add(handle.getTempData(TempDataStoreTypes.GETTER_METHODS_IMPL, className, path));
+            methods.add(getDataFromTempFileHandle(GETTER_FOR_CLASS_MASK, curNode));
 
-                methods.add(MethodsGenerator.getHashCodeMethodClose(MethodsGenerator.getHashCodeMethodOpen()
-                        + YangIoUtils
-                                .partString(handle.getTempData(TempDataStoreTypes.HASH_CODE, className, path).replace(
-                                        UtilConstants.NEW_LINE, ""))));
+            methods.add(getHashCodeMethodClose(getHashCodeMethodOpen() + partString(
+                    getDataFromTempFileHandle(HASH_CODE_IMPL_MASK, curNode).replace(UtilConstants.NEW_LINE,
+                            UtilConstants.EMPTY_STRING))));
 
-                methods.add(MethodsGenerator
-                        .getEqualsMethodClose(MethodsGenerator.getEqualsMethodOpen(className + UtilConstants.IMPL)
-                                + handle.getTempData(TempDataStoreTypes.EQUALS, className, path)));
+            methods.add(getEqualsMethodClose(getEqualsMethodOpen(className + UtilConstants.IMPL)
+                    + getDataFromTempFileHandle(EQUALS_IMPL_MASK, curNode)));
 
-                methods.add(MethodsGenerator.getToStringMethodOpen()
-                        + handle.getTempData(TempDataStoreTypes.TO_STRING, className, path)
-                        + MethodsGenerator.getToStringMethodClose());
+            methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, curNode)
+                    + 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.");
-            }
-
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while impl class file generation");
         }
 
         try {
-            methods.add(getConstructorString(className)
-                    + handle.getTempData(TempDataStoreTypes.CONSTRUCTOR, className, path)
+            methods.add(getConstructorStart(className) + getDataFromTempFileHandle(CONSTRUCTOR_IMPL_MASK, curNode)
                     + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET);
-        } 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.");
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while impl class file generation");
         }
         /**
          * Add methods in impl class.
@@ -285,56 +285,48 @@
     }
 
     /**
-     * Generate class file for type def.
+     * Return data stored in temporary files.
      *
-     * @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
+     * @param curNode current YANG node
+     * @param generatedTempFiles mask for the types of files being generated
+     * @return data stored in temporary files
+     * @throws IOException when failed to get the data from temporary file
+     *             handle
      */
-    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);
+    private static String getDataFromTempFileHandle(int generatedTempFiles, YangNode curNode) throws IOException {
 
-        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.");
+        TempJavaCodeFragmentFiles tempJavaCodeFragmentFiles = ((HasTempJavaCodeFragmentFiles) curNode)
+                .getTempJavaCodeFragmentFiles();
+
+        if ((generatedTempFiles & ATTRIBUTES_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getAttributesTempFileHandle());
+        } else if ((generatedTempFiles & GETTER_FOR_INTERFACE_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getGetterInterfaceTempFileHandle());
+        } else if ((generatedTempFiles & SETTER_FOR_INTERFACE_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getSetterInterfaceTempFileHandle());
+        } else if ((generatedTempFiles & GETTER_FOR_CLASS_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getGetterImplTempFileHandle());
+        } else if ((generatedTempFiles & SETTER_FOR_CLASS_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getSetterImplTempFileHandle());
+        } else if ((generatedTempFiles & CONSTRUCTOR_IMPL_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getConstructorImplTempFileHandle());
+        } else if ((generatedTempFiles & HASH_CODE_IMPL_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getHashCodeImplTempFileHandle());
+        } else if ((generatedTempFiles & EQUALS_IMPL_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getEqualsImplTempFileHandle());
+        } else if ((generatedTempFiles & TO_STRING_IMPL_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getToStringImplTempFileHandle());
         }
-
-        /**
-         * 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.BUILDER + UtilConstants.OBJECT
-                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
-                + UtilConstants.NEW_LINE;
-        return javadoc + constructor;
+        return null;
     }
 
     /**
@@ -349,6 +341,7 @@
      */
     private static void initiateFile(File file, String className, int type, List<String> imports,
             String pkg) throws IOException {
+
         try {
             file.createNewFile();
             appendContents(file, className, type, imports, pkg);
@@ -365,6 +358,7 @@
      * @throws IOException when fails to append contents
      */
     public static void appendFileContents(File appendFile, File srcFile) throws IOException {
+
         try {
             FileSystemUtil.appendFileContents(appendFile, srcFile);
         } catch (IOException e) {
@@ -377,184 +371,14 @@
      *
      * @param file file in which method needs to be appended
      * @param method method which needs to be appended
+     * @throws IOException IO operation failure
      */
     private static void appendMethod(File file, String method) throws IOException {
+
         insert(file, method);
     }
 
     /**
-     * Closes the current generated file.
-     *
-     * @param fileType generate file type
-     * @param yangName file name
-     * @return end of class definition string
-     */
-    public static String closeFile(int fileType, String yangName) {
-        return JavaCodeSnippetGen.getJavaClassDefClose(fileType, yangName);
-    }
-
-    /**
-     * Parses attribute info and fetch specific data and creates serialized
-     * files of it.
-     *
-     * @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, String path,
-            CachedFileHandle handle) {
-
-        String attrString = "";
-
-        String getterString = "";
-        String getterImplString = "";
-
-        String setterString = "";
-        String setterImplString = "";
-
-        String constructorString = "";
-        String typeDefString = "";
-
-        String toString = "";
-        String hashCodeString = "";
-        String equalsString = "";
-
-        className = JavaIdentifierSyntax.getCaptialCase(className);
-
-        try {
-            /*
-             * Get the attribute definition and save attributes to temporary
-             * file.
-             */
-
-            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);
-                handle.setTempData(getterString + UtilConstants.NEW_LINE,
-                        TempDataStoreTypes.GETTER_METHODS,
-                        className,
-                        path);
-
-            }
-
-            if ((genFileType & BUILDER_INTERFACE_MASK) != 0) {
-                setterString = MethodsGenerator.getSetterString(attr, className);
-                handle.setTempData(setterString + UtilConstants.NEW_LINE,
-                        TempDataStoreTypes.SETTER_METHODS,
-                        className,
-                        path);
-            }
-
-            if ((genFileType & BUILDER_CLASS_MASK) != 0) {
-                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) {
-                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 = MethodsGenerator.getHashCodeMethodOpen()
-                        + YangIoUtils.partString(
-                                MethodsGenerator.getHashCodeMethod(attr).replace(UtilConstants.NEW_LINE, ""));
-                hashCodeString = MethodsGenerator.getHashCodeMethodClose(hashCodeString) + UtilConstants.NEW_LINE;
-
-                equalsString = MethodsGenerator.getEqualsMethodOpen(className) + UtilConstants.NEW_LINE
-                        + MethodsGenerator.getEqualsMethod(attr);
-                equalsString = MethodsGenerator.getEqualsMethodClose(equalsString) + UtilConstants.NEW_LINE;
-
-                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.");
-        }
-
-    }
-
-    /**
      * Appends all the contents into a generated java file.
      *
      * @param file generated file
@@ -567,10 +391,7 @@
     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);
-        }
+        String pkgString = parsePackageString(pkg, importsList);
 
         if ((type & IMPL_CLASS_MASK) != 0) {
 
@@ -579,38 +400,68 @@
 
             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);
-                }
-            }
+            appendHeaderContents(file, pkgString, importsList);
             write(file, fileName, type, JavaDocType.IMPL_CLASS);
-        } else {
+        } else if ((type & INTERFACE_MASK) != 0) {
 
-            if ((type & INTERFACE_MASK) != 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);
-                    }
-                }
-                write(file, fileName, type, JavaDocType.INTERFACE);
-            } else if ((type & BUILDER_CLASS_MASK) != 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.BUILDER_CLASS);
+            appendHeaderContents(file, pkgString, importsList);
+            write(file, fileName, type, JavaDocType.INTERFACE);
+        } else if ((type & BUILDER_CLASS_MASK) != 0) {
+
+            appendHeaderContents(file, pkgString, importsList);
+            write(file, fileName, type, JavaDocType.BUILDER_CLASS);
+        }
+    }
+
+    /**
+     * Removes base directory path from package and generates package string for
+     * file.
+     *
+     * @param pkg generated package
+     * @param importsList list of imports
+     * @return package string
+     */
+    private static String parsePackageString(String pkg, List<String> importsList) {
+
+        if (pkg.contains(UtilConstants.ORG)) {
+            String[] strArray = pkg.split(UtilConstants.ORG);
+            pkg = UtilConstants.ORG + strArray[1].replace(UtilConstants.SLASH, UtilConstants.PERIOD);
+        }
+        if (importsList != null) {
+            if (!importsList.isEmpty()) {
+                return UtilConstants.PACKAGE + UtilConstants.SPACE + pkg + UtilConstants.SEMI_COLAN
+                        + UtilConstants.NEW_LINE;
+            } else {
+                return UtilConstants.PACKAGE + UtilConstants.SPACE + pkg + UtilConstants.SEMI_COLAN;
+            }
+        } else {
+            return UtilConstants.PACKAGE + UtilConstants.SPACE + pkg + UtilConstants.SEMI_COLAN;
+        }
+    }
+
+    /**
+     * Appends other contents to interface, builder and typedef classes. for
+     * example : ONOS copyright, imports and package.
+     *
+     * @param file generated file
+     * @param pkg generated package
+     * @param importsList list of imports
+     * @throws IOException when fails to append contents.
+     */
+    private static void appendHeaderContents(File file, String pkg, List<String> importsList) throws IOException {
+
+        insert(file, CopyrightHeader.getCopyrightHeader());
+        insert(file, pkg);
+
+        /*
+         * TODO: add the file header using
+         * JavaCodeSnippetGen.getFileHeaderComment
+         */
+
+        if (importsList != null) {
+            insert(file, UtilConstants.NEW_LINE);
+            for (String imports : importsList) {
+                insert(file, imports);
             }
         }
     }
@@ -639,6 +490,7 @@
      * @throws IOException when fails to insert into file
      */
     public static void insert(File file, String data) throws IOException {
+
         try {
             FileSystemUtil.updateFileHandle(file, data, false);
         } catch (IOException e) {
@@ -653,6 +505,7 @@
      * @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) {
@@ -666,6 +519,7 @@
      * @param file file to be removed
      */
     public static void clean(File file) {
+
         if (file.exists()) {
             file.delete();
         }
@@ -678,6 +532,7 @@
      * @throws IOException when fails to delete the directory
      */
     public static void cleanTempFiles(File tempDir) throws IOException {
+
         FileUtils.deleteDirectory(tempDir);
     }
 }
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index 2f79931..2639b8b 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -16,9 +16,13 @@
 
 package org.onosproject.yangutils.translator.tojava.utils;
 
+import java.io.File;
 import java.util.ArrayList;
 
+import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.translator.exception.TranslatorException;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
 import org.onosproject.yangutils.utils.UtilConstants;
 
 /**
@@ -61,12 +65,52 @@
     }
 
     /**
+     * Get the contained data model parent node.
+     *
+     * @param currentNode current node which parent contained node is required
+     * @return parent node in which the current node is an attribute
+     */
+    public static YangNode getParentNodeInGenCode(YangNode currentNode) {
+
+        /*
+         * TODO: recursive parent lookup to support choice/augment/uses. TODO:
+         * need to check if this needs to be updated for
+         * choice/case/augment/grouping
+         */
+        return currentNode.getParent();
+    }
+
+    /**
+     * Get the node package string.
+     *
+     * @param curNode current java node whose package string needs to be set
+     * @return returns the root package string
+     */
+    public static String getCurNodePackage(YangNode curNode) {
+
+        String pkg;
+        if (!(curNode instanceof HasJavaFileInfo)
+                || curNode.getParent() == null) {
+            throw new RuntimeException("missing parent node to get current node's package");
+        }
+
+        YangNode parentNode = getParentNodeInGenCode(curNode);
+        if (!(parentNode instanceof HasJavaFileInfo)) {
+            throw new RuntimeException("missing parent java node to get current node's package");
+        }
+        JavaFileInfo parentJavaFileHandle = ((HasJavaFileInfo) parentNode).getJavaFileInfo();
+        pkg = parentJavaFileHandle.getPackage() + UtilConstants.PERIOD + parentJavaFileHandle.getJavaName();
+        return pkg.toLowerCase();
+    }
+
+    /**
      * Returns version.
      *
      * @param ver YANG version
      * @return version
      */
     private static String getYangVersion(byte ver) {
+
         return "v" + ver;
     }
 
@@ -77,6 +121,7 @@
      * @return java package name as per java rules
      */
     public static String getPkgFromNameSpace(String nameSpace) {
+
         ArrayList<String> pkgArr = new ArrayList<String>();
         nameSpace = nameSpace.replace(UtilConstants.QUOTES, UtilConstants.EMPTY_STRING);
         String properNameSpace = nameSpace.replaceAll(UtilConstants.REGEX_WITH_SPECIAL_CHAR, UtilConstants.COLAN);
@@ -96,12 +141,13 @@
      * @throws TranslatorException when date is invalid.
      */
     public static String getYangRevisionStr(String date) throws TranslatorException {
+
         String[] revisionArr = date.split(UtilConstants.HYPHEN);
 
         String rev = "rev";
         rev = rev + revisionArr[INDEX_ZERO];
 
-        if ((Integer.parseInt(revisionArr[INDEX_ONE]) <= MAX_MONTHS)
+        if (Integer.parseInt(revisionArr[INDEX_ONE]) <= MAX_MONTHS
                 && Integer.parseInt(revisionArr[INDEX_TWO]) <= MAX_DAYS) {
             for (int i = INDEX_ONE; i < revisionArr.length; i++) {
 
@@ -131,7 +177,7 @@
         int i = 0;
         for (String member : pkgArr) {
             boolean presenceOfKeyword = UtilConstants.JAVA_KEY_WORDS.contains(member);
-            if (presenceOfKeyword || (member.matches(UtilConstants.REGEX_FOR_FIRST_DIGIT))) {
+            if (presenceOfKeyword || member.matches(UtilConstants.REGEX_FOR_FIRST_DIGIT)) {
                 member = UtilConstants.UNDER_SCORE + member;
             }
             pkg = pkg + member;
@@ -144,23 +190,13 @@
     }
 
     /**
-     * Get the package from parent's package and string.
-     *
-     * @param parentPkg parent's package
-     * @param parentName parent's name
-     * @return package string
-     */
-    public static String getPackageFromParent(String parentPkg, String parentName) {
-        return (parentPkg + UtilConstants.PERIOD + getSubPkgFromName(parentName)).toLowerCase();
-    }
-
-    /**
      * Get package sub name from YANG identifier name.
      *
      * @param name YANG identifier name
      * @return java package sub name as per java rules
      */
     public static String getSubPkgFromName(String name) {
+
         ArrayList<String> pkgArr = new ArrayList<String>();
         String[] nameArr = name.split(UtilConstants.COLAN);
 
@@ -177,6 +213,7 @@
      * @return corresponding java identifier
      */
     public static String getCamelCase(String yangIdentifier) {
+
         String[] strArray = yangIdentifier.split(UtilConstants.HYPHEN);
         String camelCase = strArray[0];
         for (int i = 1; i < strArray.length; i++) {
@@ -193,16 +230,41 @@
      * @return corresponding java identifier
      */
     public static String getCaptialCase(String yangIdentifier) {
+
         return yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1);
     }
 
     /**
-     * Translate the YANG identifier name to java identifier with first letter in small.
+     * Translate the YANG identifier name to java identifier with first letter
+     * in small.
      *
      * @param yangIdentifier identifier in YANG file.
      * @return corresponding java identifier
      */
     public static String getLowerCase(String yangIdentifier) {
+
         return yangIdentifier.substring(0, 1).toLowerCase() + yangIdentifier.substring(1);
     }
+
+    /**
+     * Get the java Package from package path.
+     *
+     * @param packagePath package path
+     * @return java package
+     */
+    public static String getJavaPackageFromPackagePath(String packagePath) {
+
+        return packagePath.replace(File.separator, UtilConstants.PERIOD);
+    }
+
+    /**
+     * Get the directory path corresponding to java package.
+     *
+     * @param packagePath package path
+     * @return java package
+     */
+    public static String getPackageDirPathFromJavaJPackage(String packagePath) {
+
+        return packagePath.replace(UtilConstants.PERIOD, File.separator);
+    }
 }
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index 576ebff..716580e 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.yangutils.translator.tojava.utils;
 
-import org.onosproject.yangutils.translator.tojava.AttributeInfo;
+import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
 import org.onosproject.yangutils.utils.UtilConstants;
 import org.onosproject.yangutils.utils.io.impl.JavaDocGen;
 import org.onosproject.yangutils.utils.io.impl.YangIoUtils;
@@ -35,25 +35,12 @@
     /**
      * Returns the methods strings for builder interface.
      *
-     * @param attr attribute info
-     * @param className name of the java class being generated
-     * @return method string for builder interface
-     */
-    static String parseBuilderInterfaceMethodString(AttributeInfo attr, String className) {
-
-        return getGetterString(attr) + UtilConstants.NEW_LINE + getSetterString(attr, className);
-    }
-
-    /**
-     * Returns the methods strings for builder interface.
-     *
      * @param name attribute name
      * @return method string for builder interface
      */
     public static String parseBuilderInterfaceBuildMethodString(String name) {
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.BUILD, name, false)
-                + getBuildForInterface(name);
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.BUILD, name, false) + getBuildForInterface(name);
     }
 
     /**
@@ -62,21 +49,13 @@
      * @param attr attribute info
      * @return getter string
      */
-    public static String getGetterString(AttributeInfo attr) {
+    public static String getGetterString(JavaAttributeInfo attr) {
 
-        String returnType = "";
-        boolean isList = attr.isListAttr();
-        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
-            returnType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-
-        returnType = returnType + attr.getImportInfo().getClassInfo();
+        String returnType = getReturnType(attr);
         String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.GETTER, attributeName, isList) +
-
-                getGetterForInterface(attributeName, returnType, attr.isListAttr())
-                + UtilConstants.NEW_LINE;
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.GETTER, attributeName, attr.isListAttr()) +
+                getGetterForInterface(attributeName, returnType, attr.isListAttr());
     }
 
     /**
@@ -86,20 +65,13 @@
      * @param className java class name
      * @return setter string
      */
-    public static String getSetterString(AttributeInfo attr, String className) {
+    public static String getSetterString(JavaAttributeInfo attr, String className) {
 
-        String attrType = "";
-        boolean isList = attr.isListAttr();
-        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
-            attrType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-
-        attrType = attrType + attr.getImportInfo().getClassInfo();
+        String attrType = getReturnType(attr);
         String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
 
-        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.SETTER, attributeName, isList)
-                + getSetterForInterface(attributeName, attrType, className, attr.isListAttr())
-                + UtilConstants.NEW_LINE;
+        return JavaDocGen.getJavaDoc(JavaDocGen.JavaDocType.SETTER, attributeName, attr.isListAttr())
+                + getSetterForInterface(attributeName, attrType, className, attr.isListAttr());
     }
 
     /**
@@ -133,13 +105,9 @@
      * @param className class name
      * @return default constructor string
      */
-    public static String getTypeDefConstructor(AttributeInfo attr, String className) {
+    public static String getTypeDefConstructor(JavaAttributeInfo attr, String className) {
 
-        String attrQuaifiedType = "";
-        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
-            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attrQuaifiedType = getReturnType(attr);
         String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
 
         if (!attr.isListAttr()) {
@@ -160,13 +128,12 @@
     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
+                + className + UtilConstants.OPEN_PARENTHESIS + type + UtilConstants.SPACE + UtilConstants.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;
+                + UtilConstants.VALUE + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
     }
 
     /**
@@ -176,6 +143,7 @@
      * @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;
@@ -199,20 +167,16 @@
      * @param attr attribute info
      * @return getter method for class
      */
-    public static String getGetterForClass(AttributeInfo attr) {
+    public static String getGetterForClass(JavaAttributeInfo attr) {
 
-        String attrQuaifiedType = "";
-        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
-            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attrQuaifiedType = getReturnType(attr);
         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);
+        return getGetter(listAttr, attributeName + UtilConstants.SUFIX_S);
     }
 
     /**
@@ -240,19 +204,15 @@
      * @param className name of the class
      * @return setter method for class
      */
-    public static String getSetterForClass(AttributeInfo attr, String className) {
+    public static String getSetterForClass(JavaAttributeInfo attr, String className) {
 
-        String attrQuaifiedType = "";
-        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
-            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attrQuaifiedType = getReturnType(attr);
         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);
+        return getSetter(className, attributeName + UtilConstants.SUFIX_S, listAttr);
     }
 
     /**
@@ -283,20 +243,16 @@
      * @param attr attribute info
      * @return setter method for class
      */
-    public static String getSetterForTypeDefClass(AttributeInfo attr) {
+    public static String getSetterForTypeDefClass(JavaAttributeInfo attr) {
 
-        String attrQuaifiedType = "";
-        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
-            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attrQuaifiedType = getReturnType(attr);
         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);
+        return getTypeDefSetter(listAttr, attributeName + UtilConstants.SUFIX_S);
     }
 
     /**
@@ -311,12 +267,12 @@
         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
+                + type + UtilConstants.SPACE + UtilConstants.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;
+                + UtilConstants.VALUE + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
     }
 
     /**
@@ -325,6 +281,7 @@
      * @return override string
      */
     public static String getOverRideString() {
+
         return UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
                 + UtilConstants.OVERRIDE + UtilConstants.NEW_LINE;
     }
@@ -343,7 +300,7 @@
             return getGetterInterfaceString(returnType, yangName);
         }
         String listAttr = getListString() + returnType + UtilConstants.DIAMOND_CLOSE_BRACKET;
-        return getGetterInterfaceString(listAttr, yangName);
+        return getGetterInterfaceString(listAttr, yangName + UtilConstants.SUFIX_S);
     }
 
     /**
@@ -378,7 +335,7 @@
             return getSetterInterfaceString(className, attrName, attrType);
         }
         String listAttr = getListString() + attrType + UtilConstants.DIAMOND_CLOSE_BRACKET;
-        return getSetterInterfaceString(className, attrName, listAttr);
+        return getSetterInterfaceString(className, attrName + UtilConstants.SUFIX_S, listAttr);
     }
 
     /**
@@ -404,10 +361,27 @@
      * @return list string
      */
     private static String getListString() {
+
         return UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET;
     }
 
     /**
+     * Returns return type for attribute.
+     *
+     * @param attr attribute info
+     * @return return type
+     */
+    private static String getReturnType(JavaAttributeInfo attr) {
+
+        String returnType = UtilConstants.EMPTY_STRING;
+        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
+            returnType = attr.getImportInfo().getPkgInfo() + UtilConstants.PERIOD;
+        }
+        returnType = returnType + attr.getImportInfo().getClassInfo();
+        return returnType;
+    }
+
+    /**
      * Returns the build method strings for interface file.
      *
      * @param yangName name of the interface
@@ -421,20 +395,39 @@
     }
 
     /**
+     * Returns constructor string for impl class.
+     *
+     * @param yangName class name
+     * @return constructor string
+     */
+    public static String getConstructorStart(String yangName) {
+
+        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 + UtilConstants.BUILDER.toLowerCase() + UtilConstants.OBJECT
+                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
+                + UtilConstants.NEW_LINE;
+        return javadoc + constructor;
+    }
+
+    /**
      * Returns the constructor strings for class file.
      *
      * @param yangName name of the class
      * @param attr attribute info
      * @return constructor for class
      */
-    public static String getConstructor(String yangName, AttributeInfo attr) {
+    public static String getConstructor(String yangName, JavaAttributeInfo attr) {
 
-        String builderAttribute = JavaIdentifierSyntax.getLowerCase(yangName);
         String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        if (attr.isListAttr()) {
+            attributeName = attributeName + UtilConstants.SUFIX_S;
+        }
         String constructor = UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS
                 + UtilConstants.PERIOD + JavaIdentifierSyntax.getCamelCase(attributeName)
-                + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE + builderAttribute
-                + UtilConstants.BUILDER + UtilConstants.OBJECT + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX
+                + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE + UtilConstants.BUILDER.toLowerCase()
+                + 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;
@@ -472,7 +465,7 @@
         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;
+                + UtilConstants.CLOSE_CURLY_BRACKET;
     }
 
     /**
@@ -483,10 +476,10 @@
     public static String getToStringMethodOpen() {
 
         return getOverRideString() + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
-                + UtilConstants.STRING + UtilConstants.SPACE + "to" + UtilConstants.STRING
+                + UtilConstants.STRING + UtilConstants.SPACE + UtilConstants.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;
+                + UtilConstants.RETURN + UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -495,10 +488,11 @@
      * @return to string method close string
      */
     public static String getToStringMethodClose() {
-        return UtilConstants.TWELVE_SPACE_INDENTATION + ".to" + UtilConstants.STRING
+
+        return UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.PERIOD + UtilConstants.TO + UtilConstants.STRING
                 + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN
                 + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
-                + UtilConstants.CLOSE_CURLY_BRACKET;
+                + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -507,8 +501,12 @@
      * @param attr attribute info
      * @return to string method
      */
-    public static String getToStringMethod(AttributeInfo attr) {
+    public static String getToStringMethod(JavaAttributeInfo attr) {
+
         String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        if (attr.isListAttr()) {
+            attributeName = attributeName + UtilConstants.SUFIX_S;
+        }
         return UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.PERIOD + UtilConstants.ADD_STRING
                 + UtilConstants.OPEN_PARENTHESIS + UtilConstants.QUOTES
                 + attributeName + UtilConstants.QUOTES + UtilConstants.COMMA + UtilConstants.SPACE + attributeName
@@ -527,7 +525,8 @@
                 + 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;
+                + UtilConstants.RETURN + UtilConstants.SPACE + UtilConstants.OBJECT_STRING + UtilConstants.SUFIX_S
+                + UtilConstants.PERIOD + UtilConstants.HASH + UtilConstants.OPEN_PARENTHESIS;
     }
 
     /**
@@ -537,10 +536,11 @@
      * @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);
         return hashcodeString + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
-                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
+                + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -549,8 +549,12 @@
      * @param attr attribute info
      * @return hash code method
      */
-    public static String getHashCodeMethod(AttributeInfo attr) {
+    public static String getHashCodeMethod(JavaAttributeInfo attr) {
+
         String attributeName = JavaIdentifierSyntax.getLowerCase(attr.getAttributeName());
+        if (attr.isListAttr()) {
+            attributeName = attributeName + UtilConstants.SUFIX_S;
+        }
         return attributeName
                 + UtilConstants.COMMA + UtilConstants.SPACE;
 
@@ -566,7 +570,7 @@
 
         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.OPEN_PARENTHESIS + UtilConstants.OBJECT_STRING + UtilConstants.SPACE + UtilConstants.OBJ
                 + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET
                 + UtilConstants.NEW_LINE + getEqualsMethodsCommonIfCondition()
                 + getEqualsMethodsSpecificIfCondition(className);
@@ -578,12 +582,13 @@
      * @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.OPEN_PARENTHESIS + UtilConstants.THIS + UtilConstants.SPACE + UtilConstants.EQUAL
+                + UtilConstants.EQUAL + UtilConstants.SPACE + UtilConstants.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;
     }
 
@@ -594,14 +599,15 @@
      * @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.OPEN_PARENTHESIS + UtilConstants.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;
+                + UtilConstants.OTHER + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE
+                + UtilConstants.OPEN_PARENTHESIS + className + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE
+                + UtilConstants.OBJ + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+                + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -611,6 +617,7 @@
      * @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);
@@ -621,7 +628,7 @@
                 + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.SPACE
                 + UtilConstants.FALSE + UtilConstants.SEMI_COLAN
                 + UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION
-                + UtilConstants.CLOSE_CURLY_BRACKET;
+                + UtilConstants.CLOSE_CURLY_BRACKET + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -630,11 +637,16 @@
      * @param attr attribute info
      * @return equals method
      */
-    public static String getEqualsMethod(AttributeInfo attr) {
+    public static String getEqualsMethod(JavaAttributeInfo 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
+        if (attr.isListAttr()) {
+            attributeName = attributeName + UtilConstants.SUFIX_S;
+        }
+        return UtilConstants.SIXTEEN_SPACE_INDENTATION + UtilConstants.SPACE + UtilConstants.OBJECT_STRING
+                + UtilConstants.SUFIX_S + UtilConstants.PERIOD + UtilConstants.EQUALS_STRING
+                + UtilConstants.OPEN_PARENTHESIS + attributeName + UtilConstants.COMMA + UtilConstants.SPACE
+                + UtilConstants.OTHER + UtilConstants.PERIOD + attributeName + UtilConstants.CLOSE_PARENTHESIS
                 + UtilConstants.SPACE + UtilConstants.AND + UtilConstants.AND;
 
     }
@@ -646,13 +658,9 @@
      * @param attr attribute info
      * @return of method string
      */
-    public static String getOfMethod(String name, AttributeInfo attr) {
+    public static String getOfMethod(String name, JavaAttributeInfo attr) {
 
-        String attrQuaifiedType = "";
-        if (attr.isQualifiedName() && (attr.getImportInfo().getPkgInfo() != null)) {
-            attrQuaifiedType = attr.getImportInfo().getPkgInfo() + ".";
-        }
-        attrQuaifiedType = attrQuaifiedType + attr.getImportInfo().getClassInfo();
+        String attrQuaifiedType = getReturnType(attr);
 
         return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + UtilConstants.STATIC
                 + UtilConstants.SPACE + name + UtilConstants.SPACE + UtilConstants.OF + UtilConstants.OPEN_PARENTHESIS