Rectify cyclic dependency among tojava.javamodel and tojava.utils.

Change-Id: Ibb4d2d7519a31bdb3eecf2f214998d4c316b7132
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaIdentityTranslator.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaIdentityTranslator.java
index 8c530f1..b96a239 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaIdentityTranslator.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/javamodel/YangJavaIdentityTranslator.java
@@ -16,10 +16,6 @@
 package org.onosproject.yang.compiler.translator.tojava.javamodel;
 
 import org.onosproject.yang.compiler.datamodel.YangIdentity;
-import org.onosproject.yang.compiler.datamodel.YangModule;
-import org.onosproject.yang.compiler.datamodel.YangNode;
-import org.onosproject.yang.compiler.datamodel.YangRevision;
-import org.onosproject.yang.compiler.datamodel.YangSubModule;
 import org.onosproject.yang.compiler.datamodel.javadatamodel.YangJavaIdentity;
 import org.onosproject.yang.compiler.translator.exception.TranslatorException;
 import org.onosproject.yang.compiler.translator.tojava.JavaCodeGenerator;
@@ -41,7 +37,6 @@
 import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
 import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGeneratorUtils.initiateJavaFileGeneration;
 import static org.onosproject.yang.compiler.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
-import static org.onosproject.yang.compiler.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
 import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getFromStringMethodForIdentity;
 import static org.onosproject.yang.compiler.translator.tojava.utils.MethodsGenerator.getToStringMethodForIdentity;
 import static org.onosproject.yang.compiler.translator.tojava.utils.TranslatorErrorType.FAIL_AT_ENTRY;
@@ -50,10 +45,8 @@
 import static org.onosproject.yang.compiler.utils.UtilConstants.CLOSE_CURLY_BRACKET;
 import static org.onosproject.yang.compiler.utils.UtilConstants.EMPTY_STRING;
 import static org.onosproject.yang.compiler.utils.UtilConstants.JAVA_FILE_EXTENSION;
-import static org.onosproject.yang.compiler.utils.UtilConstants.PERIOD;
 import static org.onosproject.yang.compiler.utils.io.impl.FileSystemUtil.closeFile;
 import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.formatFile;
-import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCamelCase;
 import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.getCapitalCase;
 import static org.onosproject.yang.compiler.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
 
@@ -203,39 +196,6 @@
         return imports;
     }
 
-    /**
-     * Gets the derived package of YangIdentity.
-     *
-     * @param id YANG Identity.
-     * @return package of identity.
-     */
-    public static String getDerivedPackage(YangIdentity id) {
-        String derPkg;
-        String version;
-        String moduleName;
-        YangRevision revision;
-        String nodeName;
-
-        YangNode node = id.getParent();
-        if (node instanceof YangModule) {
-            YangModule module = (YangModule) node;
-            version = module.getVersion();
-            moduleName = module.getModuleName();
-            revision = module.getRevision();
-            nodeName = module.getName();
-        } else {
-            YangSubModule subModule = (YangSubModule) node;
-            version = subModule.getVersion();
-            moduleName = subModule.getModuleName();
-            revision = subModule.getRevision();
-            nodeName = subModule.getName();
-        }
-        String modulePkg = getRootPackage(version, moduleName, revision, null);
-        String modJava = getCamelCase(nodeName, null);
-        derPkg = modulePkg + PERIOD + modJava.toLowerCase();
-        return derPkg;
-    }
-
     private void addStringMethodsToClass(File file, String className,
                                          List<YangIdentity> idList)
             throws IOException {
@@ -253,5 +213,4 @@
     public void generateCodeExit() throws TranslatorException {
         /* Do nothing, file is already generated in entry*/
     }
-}
-
+}
\ No newline at end of file
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java
index 42f946e..37a2eee 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/utils/JavaFileGeneratorUtils.java
@@ -24,8 +24,11 @@
 import org.onosproject.yang.compiler.datamodel.YangDataStructure;
 import org.onosproject.yang.compiler.datamodel.YangIdentity;
 import org.onosproject.yang.compiler.datamodel.YangLeafRef;
+import org.onosproject.yang.compiler.datamodel.YangModule;
 import org.onosproject.yang.compiler.datamodel.YangNode;
 import org.onosproject.yang.compiler.datamodel.YangNodeIdentifier;
+import org.onosproject.yang.compiler.datamodel.YangRevision;
+import org.onosproject.yang.compiler.datamodel.YangSubModule;
 import org.onosproject.yang.compiler.datamodel.YangType;
 import org.onosproject.yang.compiler.datamodel.utils.builtindatatype.YangDataTypes;
 import org.onosproject.yang.compiler.translator.exception.TranslatorException;
@@ -42,7 +45,6 @@
 import org.onosproject.yang.compiler.translator.tojava.TempJavaFragmentFiles;
 import org.onosproject.yang.compiler.translator.tojava.TempJavaServiceFragmentFiles;
 import org.onosproject.yang.compiler.translator.tojava.TempJavaTypeFragmentFiles;
-import org.onosproject.yang.compiler.translator.tojava.javamodel.YangJavaIdentityTranslator;
 import org.onosproject.yang.compiler.utils.io.YangPluginConfig;
 import org.onosproject.yang.compiler.utils.io.impl.JavaDocGen.JavaDocType;
 
@@ -96,6 +98,7 @@
 import static org.onosproject.yang.compiler.translator.tojava.YangJavaModelUtils.getNodesPackage;
 import static org.onosproject.yang.compiler.translator.tojava.utils.ClassDefinitionGenerator.generateClassDefinition;
 import static org.onosproject.yang.compiler.translator.tojava.utils.IndentationType.FOUR_SPACE;
+import static org.onosproject.yang.compiler.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
 import static org.onosproject.yang.compiler.translator.tojava.utils.MethodClassTypes.CLASS_TYPE;
 import static org.onosproject.yang.compiler.translator.tojava.utils.MethodClassTypes.INTERFACE_TYPE;
 import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getIfConditionBegin;
@@ -393,7 +396,7 @@
 
         if (file.exists()) {
             throw new IOException(" file " + file.getName() + " is already generated for "
-                    + className + " @ " + pkg + "\n" +
+                                          + className + " @ " + pkg + "\n" +
                                           ERROR_MSG_FOR_GEN_CODE);
         }
 
@@ -428,7 +431,7 @@
 
         if (file.exists()) {
             throw new IOException(" file " + file.getName() +
-                                  " is already generated for: " + name + "\n" +
+                                          " is already generated for: " + name + "\n" +
                                           ERROR_MSG_FOR_GEN_CODE);
         }
         boolean isFileCreated;
@@ -894,7 +897,7 @@
      * @return derived package info.
      */
     public static JavaQualifiedTypeInfoTranslator getDerivedPkfInfo(YangIdentity id) {
-        String pkg = YangJavaIdentityTranslator.getDerivedPackage(id);
+        String pkg = getDerivedPackage(id);
         String name;
         if (id.isNameConflict()) {
             name = getCapitalCase(
@@ -1047,4 +1050,37 @@
                 .append(signatureClose()).append(methodClose(FOUR_SPACE));
         return builder.toString();
     }
+
+    /**
+     * Gets the derived package of YangIdentity.
+     *
+     * @param id YANG Identity.
+     * @return package of identity.
+     */
+    public static String getDerivedPackage(YangIdentity id) {
+        String derPkg;
+        String version;
+        String moduleName;
+        YangRevision revision;
+        String nodeName;
+
+        YangNode node = id.getParent();
+        if (node instanceof YangModule) {
+            YangModule module = (YangModule) node;
+            version = module.getVersion();
+            moduleName = module.getModuleName();
+            revision = module.getRevision();
+            nodeName = module.getName();
+        } else {
+            YangSubModule subModule = (YangSubModule) node;
+            version = subModule.getVersion();
+            moduleName = subModule.getModuleName();
+            revision = subModule.getRevision();
+            nodeName = subModule.getName();
+        }
+        String modulePkg = getRootPackage(version, moduleName, revision, null);
+        String modJava = getCamelCase(nodeName, null);
+        derPkg = modulePkg + PERIOD + modJava.toLowerCase();
+        return derPkg;
+    }
 }
\ No newline at end of file