Adding builder and operation type in generated interfaces

Change-Id: I0c3ed6f01a8f933ad91ce1a46aeebc62029ca47a
diff --git a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
index 97817d4..8d08754 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaServiceFragmentFiles.java
@@ -16,15 +16,15 @@
 
 package org.onosproject.yangutils.translator.tojava;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
 import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.utils.io.YangPluginConfig;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaModuleTranslator;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaSubModuleTranslator;
 import org.onosproject.yangutils.translator.tojava.utils.JavaExtendsListHolder;
+import org.onosproject.yangutils.utils.io.YangPluginConfig;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
 
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_INTERFACE_MASK;
@@ -37,6 +37,7 @@
 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
 import static org.onosproject.yangutils.utils.UtilConstants.LISTENER_SERVICE;
 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yangutils.utils.UtilConstants.Operation.ADD;
 import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.closeFile;
@@ -45,11 +46,11 @@
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getCapitalCase;
 
 /**
- * Represents implementation of java service code fragments temporary implementations. Maintains the temp files required
- * specific for service and manager java snippet generation.
+ * Represents implementation of java service code fragments temporary
+ * implementations. Maintains the temp files required specific for service
+ * and manager java snippet generation.
  */
-public class TempJavaServiceFragmentFiles
-        extends TempJavaFragmentFiles {
+public class TempJavaServiceFragmentFiles extends TempJavaFragmentFiles {
 
     /**
      * File name for rpc method.
@@ -92,31 +93,15 @@
         setJavaExtendsListHolder(new JavaExtendsListHolder());
         setJavaImportData(new JavaImportData());
         setJavaFileInfo(javaFileInfo);
-        setAbsoluteDirPath(getAbsolutePackagePath(getJavaFileInfo().getBaseCodeGenPath(),
+        setAbsoluteDirPath(getAbsolutePackagePath(
+                getJavaFileInfo().getBaseCodeGenPath(),
                 getJavaFileInfo().getPackageFilePath()));
         addGeneratedTempFile(RPC_INTERFACE_MASK);
         addGeneratedTempFile(RPC_IMPL_MASK);
 
-        setRpcInterfaceTempFileHandle(getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME));
-        setRpcImplTempFileHandle(getTemporaryFileHandle(RPC_IMPL_FILE_NAME));
-    }
-
-    /**
-     * Returns rpc method's java file handle.
-     *
-     * @return java file handle
-     */
-    private File getServiceInterfaceJavaFileHandle() {
-        return serviceInterfaceJavaFileHandle;
-    }
-
-    /**
-     * Sets rpc method's java file handle.
-     *
-     * @param serviceInterfaceJavaFileHandle file handle for to rpc method
-     */
-    private void setServiceInterfaceJavaFileHandle(File serviceInterfaceJavaFileHandle) {
-        this.serviceInterfaceJavaFileHandle = serviceInterfaceJavaFileHandle;
+        rpcInterfaceTempFileHandle =
+                getTemporaryFileHandle(RPC_INTERFACE_FILE_NAME);
+        rpcImplTempFileHandle = getTemporaryFileHandle(RPC_IMPL_FILE_NAME);
     }
 
     /**
@@ -129,15 +114,6 @@
     }
 
     /**
-     * Sets rpc method's temporary file handle.
-     *
-     * @param rpcInterfaceTempFileHandle file handle for to rpc method
-     */
-    private void setRpcInterfaceTempFileHandle(File rpcInterfaceTempFileHandle) {
-        this.rpcInterfaceTempFileHandle = rpcInterfaceTempFileHandle;
-    }
-
-    /**
      * Retrieves the manager impl temp file.
      *
      * @return the manager impl temp file
@@ -147,15 +123,6 @@
     }
 
     /**
-     * Sets the manager impl temp file.
-     *
-     * @param rpcImplTempFileHandle the manager impl temp file
-     */
-    private void setRpcImplTempFileHandle(File rpcImplTempFileHandle) {
-        this.rpcImplTempFileHandle = rpcImplTempFileHandle;
-    }
-
-    /**
      * Constructs java code exit.
      *
      * @param fileType generated file type
@@ -167,26 +134,31 @@
             throws IOException {
 
         addResolvedAugmentedDataNodeImports(curNode);
-        List<String> imports = ((JavaCodeGeneratorInfo) curNode).getTempJavaCodeFragmentFiles().getServiceTempFiles()
+        List<String> imports = ((JavaCodeGeneratorInfo) curNode)
+                .getTempJavaCodeFragmentFiles().getServiceTempFiles()
                 .getJavaImportData().getImports();
         createPackage(curNode);
-        boolean isNotification = false;
+        boolean notification = false;
         if (curNode instanceof YangJavaModuleTranslator) {
-            if (!((YangJavaModuleTranslator) curNode).getNotificationNodes().isEmpty()) {
-                isNotification = true;
+            if (!((YangJavaModuleTranslator) curNode).getNotificationNodes()
+                    .isEmpty()) {
+                notification = true;
             }
         } else if (curNode instanceof YangJavaSubModuleTranslator) {
-            if (!((YangJavaSubModuleTranslator) curNode).getNotificationNodes().isEmpty()) {
-                isNotification = true;
+            if (!((YangJavaSubModuleTranslator) curNode).getNotificationNodes()
+                    .isEmpty()) {
+                notification = true;
             }
         }
 
-        if (isNotification) {
-            addListenersImport(curNode, imports, true, LISTENER_SERVICE);
+        if (notification) {
+            addListenersImport(curNode, imports, ADD, LISTENER_SERVICE);
         }
 
-        setServiceInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX)));
-        generateServiceInterfaceFile(getServiceInterfaceJavaFileHandle(), curNode, imports);
+        serviceInterfaceJavaFileHandle =
+                getJavaFileHandle(getJavaClassName(SERVICE_FILE_NAME_SUFFIX));
+        generateServiceInterfaceFile(serviceInterfaceJavaFileHandle, curNode,
+                                     imports);
 
         // Close all the file handles.
         freeTemporaryResources(false);
@@ -195,70 +167,70 @@
     /**
      * Adds rpc string information to applicable temp file.
      *
-     * @param javaAttributeInfoOfInput  RPCs input node attribute info
-     * @param javaAttributeInfoOfOutput RPCs output node attribute info
-     * @param rpcName                   name of the rpc function
-     * @param pluginConfig              plugin configurations
+     * @param inputAttr  RPCs input node attribute info
+     * @param outputAttr RPCs output node attribute info
+     * @param rpcName    name of the rpc function
+     * @param config     plugin configurations
      * @throws IOException IO operation fail
      */
-    private void addRpcString(JavaAttributeInfo javaAttributeInfoOfInput,
-                              JavaAttributeInfo javaAttributeInfoOfOutput, YangPluginConfig pluginConfig,
-                              String rpcName)
+    private void addRpcString(JavaAttributeInfo inputAttr,
+                              JavaAttributeInfo outputAttr,
+                              YangPluginConfig config, String rpcName)
             throws IOException {
         String rpcInput = EMPTY_STRING;
         String rpcOutput = VOID;
         String rpcInputJavaDoc = EMPTY_STRING;
-        if (javaAttributeInfoOfInput != null) {
-            rpcInput = getCapitalCase(javaAttributeInfoOfInput.getAttributeName());
+        if (inputAttr != null) {
+            rpcInput = getCapitalCase(inputAttr.getAttributeName());
         }
-        if (javaAttributeInfoOfOutput != null) {
-            rpcOutput = getCapitalCase(javaAttributeInfoOfOutput.getAttributeName());
+        if (outputAttr != null) {
+            rpcOutput = getCapitalCase(outputAttr.getAttributeName());
         }
         if (!rpcInput.equals(EMPTY_STRING)) {
             rpcInputJavaDoc = RPC_INPUT_VAR_NAME;
         }
-        appendToFile(getRpcInterfaceTempFileHandle(),
-                generateJavaDocForRpc(rpcName, rpcInputJavaDoc, rpcOutput, pluginConfig)
-                        + getRpcServiceMethod(rpcName, rpcInput, rpcOutput, pluginConfig) + NEW_LINE);
-        appendToFile(getRpcImplTempFileHandle(),
-                getRpcManagerMethod(rpcName, rpcInput, rpcOutput, pluginConfig) + NEW_LINE);
+        appendToFile(rpcInterfaceTempFileHandle,
+                     generateJavaDocForRpc(rpcName, rpcInputJavaDoc, rpcOutput,
+                                           config) +
+                             getRpcServiceMethod(rpcName, rpcInput, rpcOutput,
+                                                 config) + NEW_LINE);
+        appendToFile(rpcImplTempFileHandle,
+                     getRpcManagerMethod(rpcName, rpcInput, rpcOutput, config) +
+                             NEW_LINE);
     }
 
     /**
      * Adds the JAVA rpc snippet information.
      *
-     * @param javaAttributeInfoOfInput  RPCs input node attribute info
-     * @param javaAttributeInfoOfOutput RPCs output node attribute info
-     * @param pluginConfig              plugin configurations
-     * @param rpcName                   name of the rpc function
+     * @param inputAttr  RPCs input node attribute info
+     * @param outputAttr RPCs output node attribute info
+     * @param config     plugin configurations
+     * @param rpcName    name of the rpc function
      * @throws IOException IO operation fail
      */
-    public void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfoOfInput,
-                                                        JavaAttributeInfo javaAttributeInfoOfOutput,
-                                                        YangPluginConfig pluginConfig, String rpcName)
+    public void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo inputAttr,
+                                                        JavaAttributeInfo outputAttr,
+                                                        YangPluginConfig config,
+                                                        String rpcName)
             throws IOException {
-        addRpcString(javaAttributeInfoOfInput, javaAttributeInfoOfOutput, pluginConfig, rpcName);
+        addRpcString(inputAttr, outputAttr, config, rpcName);
     }
 
     /**
      * Removes all temporary file handles.
      *
-     * @param isErrorOccurred flag to tell translator that error has occurred while file generation
+     * @param errorOccurred flag indicating error
      * @throws IOException when failed to delete the temporary files
      */
     @Override
-    public void freeTemporaryResources(boolean isErrorOccurred)
+    public void freeTemporaryResources(boolean errorOccurred)
             throws IOException {
-
-        closeFile(getServiceInterfaceJavaFileHandle(), isErrorOccurred);
-
-        closeFile(getRpcInterfaceTempFileHandle(), true);
-        closeFile(getRpcImplTempFileHandle(), true);
-        closeFile(getGetterInterfaceTempFileHandle(), true);
-        closeFile(getSetterInterfaceTempFileHandle(), true);
-        closeFile(getSetterImplTempFileHandle(), true);
-
-        super.freeTemporaryResources(isErrorOccurred);
-
+        closeFile(serviceInterfaceJavaFileHandle, errorOccurred);
+        closeFile(rpcInterfaceTempFileHandle);
+        closeFile(rpcImplTempFileHandle);
+        closeFile(getGetterInterfaceTempFileHandle());
+        closeFile(getSetterInterfaceTempFileHandle());
+        closeFile(getSetterImplTempFileHandle());
+        super.freeTemporaryResources(errorOccurred);
     }
 }