[ONOS-3908] Implemetation of YANG container translator.

Change-Id: I9ffcfc4b370edb801dfc90c5394cef787c77641d
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/CachedJavaFileHandle.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/CachedJavaFileHandle.java
index 86656e9..ac917aa 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/CachedJavaFileHandle.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/CachedJavaFileHandle.java
@@ -18,6 +18,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.SortedSet;
@@ -68,6 +69,11 @@
     private String pkg;
 
     /**
+     * Java package in which the child class/interface needs to be generated.
+     */
+    private String childsPkg;
+
+    /**
      * Name of the object in YANG file.
      */
     private String yangName;
@@ -76,7 +82,7 @@
      * 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;
+    private SortedSet<String> importSet;
 
     /**
      * Cached list of attribute info.
@@ -171,11 +177,30 @@
     }
 
     /**
+     * Get the java package.
+     *
+     * @return the java package.
+     */
+    public String getChildsPackage() {
+        return childsPkg;
+    }
+
+    /**
+     * Set the java package.
+     *
+     * @param pcg the package to set
+     */
+    @Override
+    public void setChildsPackage(String pcg) {
+        childsPkg = pcg;
+    }
+
+    /**
      * Get the set containing the imported class/interface info.
      *
      * @return the set containing the imported class/interface info.
      */
-    public SortedSet<ImportInfo> getImportSet() {
+    public SortedSet<String> getImportSet() {
         return importSet;
     }
 
@@ -184,7 +209,7 @@
      *
      * @param importSet the set containing the imported class/interface info.
      */
-    private void setImportSet(SortedSet<ImportInfo> importSet) {
+    private void setImportSet(SortedSet<String> importSet) {
         this.importSet = importSet;
     }
 
@@ -203,9 +228,9 @@
          * be used in the generated class.
          */
         if (getImportSet() == null) {
-            setImportSet(new TreeSet<ImportInfo>());
+            setImportSet(new TreeSet<String>());
         }
-        return getImportSet().add(importInfo);
+        return getImportSet().add(JavaCodeSnippetGen.getImportText(importInfo));
     }
 
     /**
@@ -253,23 +278,42 @@
     public void addAttributeInfo(YangType<?> attrType, String name, boolean isListAttr) {
 
         AttributeInfo newAttr = new AttributeInfo();
-        attrType.setDataTypeName(attrType.getDataTypeName().replace("\"", ""));
-        if (attrType.getDataTypeName().equals("string")) {
-            attrType.setDataTypeName(
-                    attrType.getDataTypeName().substring(0, 1).toUpperCase() + attrType.getDataTypeName().substring(1));
+        if (attrType != null) {
+            attrType.setDataTypeName(attrType.getDataTypeName().replace("\"", ""));
+            if (attrType.getDataTypeName().equals("string")) {
+                attrType.setDataTypeName(JavaIdentifierSyntax.getCaptialCase(attrType.getDataTypeName()));
+            }
+            newAttr.setAttributeType(attrType);
+        } else {
+            ImportInfo importInfo = new ImportInfo();
+            importInfo.setPkgInfo(getChildsPackage());
+            importInfo.setClassInfo(JavaIdentifierSyntax.getCaptialCase(name));
+            if (getImportSet() != null) {
+                getImportSet().add(JavaCodeSnippetGen.getImportText(importInfo));
+            } else {
+                SortedSet<String> newImportInfo = new TreeSet<>();
+                newImportInfo.add(JavaCodeSnippetGen.getImportText(importInfo));
+                setImportSet(newImportInfo);
+            }
+
+            newAttr.setQualifiedName(getQualifiedFlag(JavaCodeSnippetGen.getImportText(importInfo)));
         }
-        newAttr.setAttributeType(attrType);
         newAttr.setAttributeName(name);
         newAttr.setListAttr(isListAttr);
 
-        /*
-         * TODO: get the prefix and name of data type from attrType and
-         * initialize in importInfo.
-         */
+        if (isListAttr) {
+            String listImport = UtilConstants.COLLECTION_IMPORTS + UtilConstants.LIST + UtilConstants.SEMI_COLAN
+                    + UtilConstants.NEW_LINE + UtilConstants.NEW_LINE;
+            if (getImportSet() != null) {
+                getImportSet().add(listImport);
+            } else {
+                SortedSet<String> newImportInfo = new TreeSet<>();
+                newImportInfo.add(listImport);
+                setImportSet(newImportInfo);
+            }
 
-        /**
-         * TODO: Handle QualifiedFlag for imports.
-         */
+            newAttr.setQualifiedName(getQualifiedFlag(listImport));
+        }
 
         if (getCachedAttributeList() != null) {
             if (getCachedAttributeList().size() == MAX_CACHABLE_ATTR) {
@@ -281,7 +325,32 @@
             newAttributeInfo.add(newAttr);
             setCachedAttributeList(newAttributeInfo);
         }
-        name = JavaIdentifierSyntax.getCamelCase(name);
+    }
+
+    /**
+     * Check if the import set does not have a class info same as the new class
+     * info, if so the new class info be added to the import set. Otherwise
+     * check if the corresponding package info is same as the new package info,
+     * if so no need to qualified access, otherwise, it needs qualified access.
+     *
+     * @param newImportInfo new import info to be check for qualified access or
+     *            not and updated in the import set accordingly.
+     * @return if the new attribute needs to be accessed in a qualified manner.
+     */
+    private boolean getQualifiedFlag(String newImportInfo) {
+        for (String curImportInfo : getImportSet()) {
+            if (curImportInfo.equals(newImportInfo)) {
+                /*
+                 * If import is already existing import with same package, we
+                 * don't need qualified access, otherwise it needs to be
+                 * qualified access.
+                 */
+                return !curImportInfo.equals(newImportInfo);
+            }
+        }
+
+        getImportSet().add(newImportInfo);
+        return false;
     }
 
     /**
@@ -291,7 +360,7 @@
     public void close() throws IOException {
 
         String className = getYangName();
-        className = (className.substring(0, 1).toUpperCase() + className.substring(1));
+        className = JavaIdentifierSyntax.getCaptialCase(className);
         String packagePath = getPackage();
         String filePath = UtilConstants.YANG_GEN_DIR + packagePath.replace(".", "/");
         GeneratedFileType fileType = getGeneratedFileTypes();
@@ -322,60 +391,18 @@
         String implFileName = className + UtilConstants.IMPL + TEMP_FILE_EXTENSION;
         File implTempFile = new File(filePath + File.separator + implFileName);
 
-        if (fileType.equals(GeneratedFileType.INTERFACE) || fileType.equals(GeneratedFileType.ALL)) {
-
-            try {
-                interfaceFile.createNewFile();
-                appendContents(interfaceFile, className, GeneratedFileType.INTERFACE);
-            } catch (IOException e) {
-                throw new IOException("Failed to create interface file.");
-            }
-        }
-
-        if (fileType.equals(GeneratedFileType.BUILDER_CLASS) || fileType.equals(GeneratedFileType.ALL)) {
-
-            try {
-                builderFile.createNewFile();
-                appendContents(builderFile, className, GeneratedFileType.BUILDER_CLASS);
-            } catch (IOException e) {
-                throw new IOException("Failed to create builder class file.");
-            }
-        }
-
-        if (fileType.equals(GeneratedFileType.IMPL) || fileType.equals(GeneratedFileType.ALL)) {
-
-            try {
-                implTempFile.createNewFile();
-                appendContents(implTempFile, className, GeneratedFileType.IMPL);
-            } catch (IOException e) {
-                throw new IOException("Failed to create impl class file.");
-            }
-        }
-
-        if (fileType.equals(GeneratedFileType.BUILDER_INTERFACE) || fileType.equals(GeneratedFileType.ALL)) {
-
-            try {
-                builderInterfaceFile.createNewFile();
-                appendContents(builderInterfaceFile, className, GeneratedFileType.BUILDER_INTERFACE);
-            } catch (IOException e) {
-                throw new IOException("Failed to create builder interface class file.");
-            }
-        }
         /*
          * TODO: add the file header using
          * JavaCodeSnippetGen.getFileHeaderComment
          */
-        /*
-         * TODO: get the import list using getImportText and add to the
-         * generated java file using JavaCodeSnippetGen.getImportText
-         */
 
         List<String> attributes = new LinkedList<>();
         List<String> interfaceMethods = new LinkedList<>();
         List<String> builderInterfaceMethods = new LinkedList<>();
         List<String> builderClassMethods = new LinkedList<>();
         List<String> implClassMethods = new LinkedList<>();
-        //TODO: Handle imports for the attributes.
+        List<String> imports = new LinkedList<>();
+
         try {
             attributes = SerializedDataStore.getSerializeData(SerializedDataStore.SerializedDataStoreType.ATTRIBUTE);
 
@@ -391,7 +418,7 @@
             implClassMethods = SerializedDataStore
                     .getSerializeData(SerializedDataStore.SerializedDataStoreType.IMPL_METHODS);
 
-            //TODO:imports = SerializedDataStore.getSerializeData(SerializedDataStore.SerializedDataStoreType.IMPORT);
+            imports = SerializedDataStore.getSerializeData(SerializedDataStore.SerializedDataStoreType.IMPORT);
         } catch (ClassNotFoundException | IOException e) {
             log.info("There is no attribute info of " + className + " YANG file in the serialized files.");
         }
@@ -399,6 +426,14 @@
         if (getCachedAttributeList() != null) {
             MethodsGenerator.setAttrInfo(getCachedAttributeList());
             for (AttributeInfo attr : getCachedAttributeList()) {
+                if (attr.isListAttr()) {
+                    String listString = JavaCodeSnippetGen.getListAttribute(attr.getAttributeType().getDataTypeName());
+                    @SuppressWarnings("rawtypes")
+                    YangType<?> type = new YangType();
+                    type.setDataTypeName(listString);
+                    attr.setAttributeType(type);
+                }
+
                 attributes.add(getAttributeString(attr));
 
                 interfaceMethods.add(MethodsGenerator.getMethodString(attr, GeneratedFileType.INTERFACE));
@@ -409,6 +444,10 @@
                 .add(MethodsGenerator.getMethodString(attr, GeneratedFileType.BUILDER_INTERFACE));
 
                 implClassMethods.add(MethodsGenerator.getMethodString(attr, GeneratedFileType.IMPL));
+
+                if (getImportSet() != null) {
+                    imports = new ArrayList<>(getImportSet());
+                }
             }
         }
 
@@ -422,6 +461,25 @@
         implClassMethods.add(MethodsGenerator.getConstructorString(className));
 
         /**
+         * Start generation of files.
+         */
+        if (fileType.equals(GeneratedFileType.INTERFACE) || fileType.equals(GeneratedFileType.ALL)) {
+            initiateFile(interfaceFile, className, GeneratedFileType.INTERFACE, imports);
+        }
+
+        if (fileType.equals(GeneratedFileType.BUILDER_CLASS) || fileType.equals(GeneratedFileType.ALL)) {
+            initiateFile(builderFile, className, GeneratedFileType.BUILDER_CLASS, imports);
+        }
+
+        if (fileType.equals(GeneratedFileType.IMPL) || fileType.equals(GeneratedFileType.ALL)) {
+            initiateFile(implTempFile, className, GeneratedFileType.IMPL, imports);
+        }
+
+        if (fileType.equals(GeneratedFileType.BUILDER_INTERFACE) || fileType.equals(GeneratedFileType.ALL)) {
+            initiateFile(builderInterfaceFile, className, GeneratedFileType.BUILDER_INTERFACE, imports);
+        }
+
+        /**
          * Add attributes to the file.
          */
         for (String attribute : attributes) {
@@ -483,6 +541,25 @@
     }
 
     /**
+     * Initiate generation of file based on generated file type.
+     *
+     * @param file generated file
+     * @param className generated file class name
+     * @param type generated file type
+     * @param imports imports for the file
+     * @throws IOException when fails to generate a file
+     */
+    private void initiateFile(File file, String className, GeneratedFileType type, List<String> imports)
+            throws IOException {
+        try {
+            file.createNewFile();
+            appendContents(file, className, type, imports);
+        } catch (IOException e) {
+            throw new IOException("Failed to create " + file.getName() + " class file.");
+        }
+    }
+
+    /**
      * Appends the temp files to main files.
      *
      * @param appendFile temp file
@@ -584,7 +661,8 @@
      * @param fileName generated file name
      * @param type generated file type
      */
-    private void appendContents(File file, String fileName, GeneratedFileType type) throws IOException {
+    private void appendContents(File file, String fileName, GeneratedFileType type, List<String> importsList)
+            throws IOException {
 
         if (type.equals(GeneratedFileType.IMPL)) {
 
@@ -599,12 +677,20 @@
             if (type.equals(GeneratedFileType.INTERFACE)) {
                 insert(file, CopyrightHeader.getCopyrightHeader());
                 insert(file, "package" + UtilConstants.SPACE + getPackage() + UtilConstants.SEMI_COLAN
-                        + UtilConstants.NEW_LINE);
+                        + UtilConstants.NEW_LINE + UtilConstants.NEW_LINE);
+                for (String imports : importsList) {
+                    insert(file, imports);
+                }
+                insert(file, UtilConstants.NEW_LINE);
                 write(file, fileName, type, JavaDocType.INTERFACE);
             } else if (type.equals(GeneratedFileType.BUILDER_CLASS)) {
                 insert(file, CopyrightHeader.getCopyrightHeader());
                 insert(file, "package" + UtilConstants.SPACE + getPackage() + UtilConstants.SEMI_COLAN
-                        + UtilConstants.NEW_LINE);
+                        + UtilConstants.NEW_LINE + UtilConstants.NEW_LINE);
+                for (String imports : importsList) {
+                    insert(file, imports);
+                }
+                insert(file, UtilConstants.NEW_LINE);
                 write(file, fileName, type, JavaDocType.BUILDER_CLASS);
             }
         }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
index 000ab8b..50b0d06 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaCodeGenerator.java
@@ -42,18 +42,19 @@
         TraversalType curTraversal = TraversalType.ROOT;
 
         while (!(curNode == null)) {
-            if (curTraversal != TraversalType.PARENT) {
+            if (curTraversal != TraversalType.PARENT || curTraversal == TraversalType.SIBILING) {
                 curNode.generateJavaCodeEntry();
             }
             if (curTraversal != TraversalType.PARENT && !(curNode.getChild() == null)) {
                 curTraversal = TraversalType.CHILD;
                 curNode = curNode.getChild();
-            } else if (!(curNode.getNextSibling() == null)) {
+            } else if (curTraversal == TraversalType.PARENT && !(curNode.getNextSibling() == null)) {
+                curNode.generateJavaCodeExit();
                 curTraversal = TraversalType.SIBILING;
                 curNode = curNode.getNextSibling();
             } else {
-                curTraversal = TraversalType.PARENT;
                 curNode.generateJavaCodeExit();
+                curTraversal = TraversalType.PARENT;
                 curNode = curNode.getParent();
             }
         }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
index 5998342..e8bade3 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaCodeSnippetGen.java
@@ -16,9 +16,6 @@
 
 package org.onosproject.yangutils.translator.tojava.utils;
 
-import java.util.List;
-import java.util.SortedSet;
-
 import org.onosproject.yangutils.datamodel.YangType;
 import org.onosproject.yangutils.translator.GeneratedFileType;
 import org.onosproject.yangutils.translator.tojava.GeneratedMethodTypes;
@@ -50,29 +47,15 @@
     }
 
     /**
-     * reorder the import list based on the ONOS import rules.
-     *
-     * @param importInfo the set of classes/interfaces to be imported.
-     * @return string of import info.
-     */
-    public List<ImportInfo> sortImportOrder(SortedSet<ImportInfo> importInfo) {
-        /* TODO: reorder the import list based on the ONOS import rules. */
-        return null;
-    }
-
-    /**
      * Get the textual java code information corresponding to the import list.
      *
-     * @param importInfo sorted list of import info.
+     * @param importInfo import info.
      * @return the textual java code information corresponding to the import
      *         list.
      */
-    public static String getImportText(List<ImportInfo> importInfo) {
-        /*
-         * TODO: get the textual java code information corresponding to the
-         * import list
-         */
-        return null;
+    public static String getImportText(ImportInfo importInfo) {
+        return UtilConstants.IMPORT + importInfo.getPkgInfo() + UtilConstants.PERIOD + importInfo.getClassInfo()
+        + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE;
     }
 
     /**
@@ -101,8 +84,22 @@
      */
     public static String getJavaAttributeInfo(GeneratedFileType genFileTypes, String yangName, YangType<?> type) {
         yangName = JavaIdentifierSyntax.getCamelCase(yangName);
-        return UtilConstants.PRIVATE + UtilConstants.SPACE + type.getDataTypeName() + UtilConstants.SPACE + yangName
-                + UtilConstants.SEMI_COLAN;
+        if (type != null) {
+            return UtilConstants.PRIVATE + UtilConstants.SPACE + type.getDataTypeName() + UtilConstants.SPACE + yangName
+                    + UtilConstants.SEMI_COLAN;
+        }
+        return UtilConstants.PRIVATE + UtilConstants.SPACE + JavaIdentifierSyntax.getCaptialCase(yangName)
+        + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN;
+    }
+
+    /**
+     * Returns list attribute string.
+     *
+     * @param type attribute type
+     * @return list attribute string
+     */
+    public static String getListAttribute(String type) {
+        return UtilConstants.LIST + UtilConstants.DIAMOND_OPEN_BRACKET + type + UtilConstants.DIAMOND_CLOSE_BRACKET;
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index 94bcfeb..cd26056a 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -163,4 +163,14 @@
         }
         return camelCase;
     }
+
+    /**
+     * Translate the YANG identifier name to java identifier with first letter in caps.
+     *
+     * @param yangIdentifier identifier in YANG file.
+     * @return corresponding java identifier
+     */
+    public static String getCaptialCase(String yangIdentifier) {
+        return yangIdentifier.substring(0, 1).toUpperCase() + yangIdentifier.substring(1);
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index 604caf6..2092441 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -112,6 +112,13 @@
     public static String constructMethodInfo(GeneratedFileType genFileTypes, String yangName,
             GeneratedMethodTypes methodTypes, YangType<?> returnType) {
 
+        if (returnType == null) {
+            @SuppressWarnings("rawtypes")
+            YangType<?> type = new YangType();
+            type.setDataTypeName(yangName);
+            returnType = type;
+        }
+
         if (genFileTypes.equals(GeneratedFileType.INTERFACE)) {
 
             /**
@@ -177,12 +184,10 @@
 
         String overrideString = UtilConstants.NEW_LINE + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.OVERRIDE
                 + UtilConstants.NEW_LINE;
-
         String getterString = JavaCodeSnippetGen.getJavaMethodInfo(GeneratedFileType.BUILDER_CLASS,
                 attr.getAttributeName(), GeneratedMethodTypes.GETTER, attr.getAttributeType());
         String setterString = JavaCodeSnippetGen.getJavaMethodInfo(GeneratedFileType.BUILDER_CLASS,
                 attr.getAttributeName(), GeneratedMethodTypes.SETTER, attr.getAttributeType());
-
         return overrideString + getterString + UtilConstants.NEW_LINE + overrideString + setterString
                 + UtilConstants.NEW_LINE;
     }
@@ -299,7 +304,8 @@
     private static String getGetterForClass(String yangName, YangType<?> returnType) {
 
         return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE
-                + returnType.getDataTypeName() + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX + yangName
+                + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName()) + UtilConstants.SPACE
+                + UtilConstants.GET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName)
                 + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE
                 + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION
                 + UtilConstants.RETURN + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN
@@ -316,13 +322,14 @@
     private static String getSetterForClass(String yangName, YangType<?> returnType) {
 
         return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.PUBLIC + UtilConstants.SPACE + getBuilderClassName()
-        + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX + yangName + UtilConstants.OPEN_PARENTHESIS
-        + returnType.getDataTypeName() + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS
-        + UtilConstants.SPACE + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE
-        + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.THIS + UtilConstants.PERIOD + yangName
-        + UtilConstants.SPACE + UtilConstants.EQUAL + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN
-        + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN
-        + UtilConstants.SPACE + UtilConstants.THIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+        + UtilConstants.SPACE + UtilConstants.SET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName)
+        + UtilConstants.OPEN_PARENTHESIS + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName())
+        + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SPACE
+        + UtilConstants.OPEN_CURLY_BRACKET + UtilConstants.NEW_LINE + UtilConstants.EIGHT_SPACE_INDENTATION
+        + UtilConstants.THIS + UtilConstants.PERIOD + yangName + UtilConstants.SPACE + UtilConstants.EQUAL
+        + UtilConstants.SPACE + yangName + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
+        + UtilConstants.EIGHT_SPACE_INDENTATION + UtilConstants.RETURN + UtilConstants.SPACE
+        + UtilConstants.THIS + UtilConstants.SEMI_COLAN + UtilConstants.NEW_LINE
         + UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.CLOSE_CURLY_BRACKET;
     }
 
@@ -335,9 +342,9 @@
      */
     private static String getGetterForInterface(String yangName, YangType<?> returnType) {
         returnType.setDataTypeName(returnType.getDataTypeName().replace("\"", ""));
-        return UtilConstants.FOUR_SPACE_INDENTATION + returnType.getDataTypeName() + UtilConstants.SPACE
-                + UtilConstants.GET_METHOD_PREFIX + yangName + UtilConstants.OPEN_PARENTHESIS
-                + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN;
+        return UtilConstants.FOUR_SPACE_INDENTATION + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName())
+        + UtilConstants.SPACE + UtilConstants.GET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName)
+        + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN;
     }
 
     /**
@@ -349,9 +356,9 @@
      */
     private static String getSetterForInterface(String yangName, YangType<?> returnType) {
         return UtilConstants.FOUR_SPACE_INDENTATION + UtilConstants.BUILDER + UtilConstants.SPACE
-                + UtilConstants.SET_METHOD_PREFIX + yangName + UtilConstants.OPEN_PARENTHESIS
-                + returnType.getDataTypeName() + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS
-                + UtilConstants.SEMI_COLAN;
+                + UtilConstants.SET_METHOD_PREFIX + JavaIdentifierSyntax.getCaptialCase(yangName)
+                + UtilConstants.OPEN_PARENTHESIS + JavaIdentifierSyntax.getCaptialCase(returnType.getDataTypeName())
+                + UtilConstants.SPACE + yangName + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN;
     }
 
     /**
@@ -387,7 +394,8 @@
                 constructor = constructor + UtilConstants.TWELVE_SPACE_INDENTATION + UtilConstants.THIS
                         + UtilConstants.PERIOD + attribute.getAttributeName() + UtilConstants.SPACE
                         + UtilConstants.EQUAL + UtilConstants.SPACE + builderAttribute + UtilConstants.OBJECT
-                        + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX + attribute.getAttributeName()
+                        + UtilConstants.PERIOD + UtilConstants.GET_METHOD_PREFIX
+                        + JavaIdentifierSyntax.getCaptialCase(attribute.getAttributeName())
                         + UtilConstants.OPEN_PARENTHESIS + UtilConstants.CLOSE_PARENTHESIS + UtilConstants.SEMI_COLAN
                         + UtilConstants.NEW_LINE;
             }