multiFileYangTranslator

Change-Id: I2adfef3acaec4bd74ba2c487404d2c655b800988
diff --git a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
index 9b0ccca..370e0f6 100644
--- a/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
+++ b/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
@@ -17,10 +17,12 @@
 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.exception.TranslatorException;
+import org.onosproject.yangutils.translator.tojava.javamodel.JavaLeafInfoContainer;
 import org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType;
+
 import com.google.common.base.MoreObjects;
 
 import static org.onosproject.yangutils.translator.tojava.utils.AttributesJavaDataType.getJavaImportClass;
@@ -29,8 +31,8 @@
 /**
  * Represents the information about individual imports in the generated file.
  */
-public class JavaQualifiedTypeInfo implements Comparable<JavaQualifiedTypeInfo> {
-
+public class JavaQualifiedTypeInfo
+        implements Comparable<JavaQualifiedTypeInfo> {
     /**
      * Package location where the imported class/interface is defined.
      */
@@ -84,40 +86,31 @@
     }
 
     /**
-     * Returns the import info for an attribute, which needs to be used for code
-     * generation for import or for qualified access.
+     * Updates the leaf's java information.
      *
-     * @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
+     * @param leaf leaf whose jave information is being updated
      */
-    public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfAttribute(YangNode curNode,
-                                                                        YangType<?> attrType, String attributeName,
-                                                                        boolean isListAttr) {
+    public static void updateLeavesJavaQualifiedInfo(JavaLeafInfoContainer leaf) {
 
-        JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo();
+        JavaQualifiedTypeInfo importInfo = leaf.getJavaQualifiedInfo();
 
-        if (attrType == null) {
-            throw new TranslatorException("missing data type of leaf " + attributeName);
+        if (leaf.getDataType() == null) {
+            throw new TranslatorException("missing data type of leaf " + leaf.getName());
         }
 
         /*
          * Current leaves holder is adding a leaf info as a attribute to the
          * current class.
          */
-        String className = getJavaImportClass(attrType, isListAttr);
+        String className = AttributesJavaDataType.getJavaImportClass(leaf.getDataType(), leaf.isLeafList());
         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 = getJavaImportPackage(attrType, isListAttr, className);
+            String classPkg = AttributesJavaDataType.getJavaImportPackage(leaf.getDataType(),
+                    leaf.isLeafList(), className);
             if (classPkg == null) {
                 throw new TranslatorException("import package cannot be null when the class is used");
             }
@@ -127,32 +120,30 @@
              * The attribute does not need a class to be imported, for example
              * built in java types.
              */
-            String dataTypeName = AttributesJavaDataType.getJavaDataType(attrType);
+            String dataTypeName = AttributesJavaDataType.getJavaDataType(leaf.getDataType());
             if (dataTypeName == null) {
                 throw new TranslatorException("not supported data type");
             }
             importInfo.setClassInfo(dataTypeName);
         }
-        return importInfo;
     }
 
     /**
      * Returns 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 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
+     * import info for child class
      * @return return the import info for this attribute
      */
     public static JavaQualifiedTypeInfo getQualifiedTypeInfoOfCurNode(YangNode curNode,
-                                                                      String attributeName, boolean isListAttr) {
+            String attributeName) {
 
         JavaQualifiedTypeInfo importInfo = new JavaQualifiedTypeInfo();
 
-        if (!(curNode instanceof HasJavaFileInfo)) {
+        if (!(curNode instanceof JavaFileInfoContainer)) {
             throw new TranslatorException("missing java file information to get the package details "
                     + "of attribute corresponding to child node");
         }
@@ -162,8 +153,8 @@
          * classes package with current classes name.
          */
         importInfo.setClassInfo(attributeName);
-        importInfo.setPkgInfo((((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage() + "."
-                + ((HasJavaFileInfo) curNode).getJavaFileInfo().getJavaName()).toLowerCase());
+        importInfo.setPkgInfo((((JavaFileInfoContainer) curNode).getJavaFileInfo().getPackage() + "."
+                + ((JavaFileInfoContainer) curNode).getJavaFileInfo().getJavaName()).toLowerCase());
 
         return importInfo;
     }
@@ -187,82 +178,6 @@
         return qualifiedInfoOfFromString;
     }
 
-    /**
-     * Returns 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 TranslatorException("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 TranslatorException("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;
-    }
-
-    /**
-     * Checks 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 TranslatorException("missing java file info for the data model node");
-        }
-        return ((HasJavaFileInfo) curNode).getJavaFileInfo().getPackage()
-                .contentEquals(importInfo.getPkgInfo());
-    }
 
     @Override
     public int hashCode() {