[ONOS-4302] RPC translator implementation

Change-Id: I457f12a2b0edaadee5ff888e0297b40854d53096
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasRpcNotification.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasRpcNotification.java
new file mode 100644
index 0000000..9d4d5f1
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasRpcNotification.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2016-present 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.datamodel;
+
+/**
+ * Represents class having rpc and notification.
+ */
+public interface HasRpcNotification {
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index 0c4ec87..c902389 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -17,7 +17,6 @@
 
 import java.util.LinkedList;
 import java.util.List;
-
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.utils.YangConstructType;
@@ -69,7 +68,8 @@
  * Represents data model node to maintain information defined in YANG module.
  */
 public class YangModule extends YangNode
-        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo {
+        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo,
+        HasRpcNotification {
 
     /**
      * Name of the module.
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
index 68c2ea4..9db0469 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
@@ -17,7 +17,6 @@
 
 import java.util.LinkedList;
 import java.util.List;
-
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.utils.YangConstructType;
@@ -72,11 +71,13 @@
  *                | YANG-version | 7.1.2   | 0..1        | - int            |
  *                +--------------+---------+-------------+------------------+
  */
+
 /**
  * Represents data model node to maintain information defined in YANG sub-module.
  */
 public class YangSubModule extends YangNode
-        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo {
+        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo,
+        HasRpcNotification {
 
     /**
      * Name of sub module.
@@ -183,6 +184,7 @@
      * sub-statements of each ancestor statement.
      */
     private List<YangResolutionInfo> unresolvedResolutionList;
+
     /**
      * Creates a sub module node.
      */
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/InputListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/InputListener.java
index 66233fc..bb1ba85 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/InputListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/InputListener.java
@@ -31,10 +31,10 @@
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 import static org.onosproject.yangutils.utils.YangConstructType.INPUT_DATA;
 
@@ -65,7 +65,7 @@
  */
 public final class InputListener {
 
-    private static final String INPUT_KEYWORD = "Input";
+    private static final String INPUT_KEYWORD = "_input";
 
     /**
      * Creates a new input listener.
@@ -78,10 +78,10 @@
      * (input), performs validation and updates the data model tree.
      *
      * @param listener listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processInputEntry(TreeWalkListener listener,
-                                       GeneratedYangParser.InputStatementContext ctx) {
+                                         GeneratedYangParser.InputStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", ENTRY);
@@ -110,10 +110,10 @@
      * validations and updates the data model tree.
      *
      * @param listener listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processInputExit(TreeWalkListener listener,
-                                      GeneratedYangParser.InputStatementContext ctx) {
+                                        GeneratedYangParser.InputStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, INPUT_DATA, "", EXIT);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OutputListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OutputListener.java
index f0df739..2dfa2ed 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OutputListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/OutputListener.java
@@ -31,7 +31,10 @@
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.*;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 import static org.onosproject.yangutils.utils.YangConstructType.OUTPUT_DATA;
 
@@ -62,7 +65,7 @@
  */
 public final class OutputListener {
 
-    private static final String OUTPUT_KEYWORD = "Output";
+    private static final String OUTPUT_KEYWORD = "_output";
 
     /**
      * Creates a new output listener.
@@ -75,10 +78,10 @@
      * (output), performs validation and updates the data model tree.
      *
      * @param listener listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processOutputEntry(TreeWalkListener listener,
-                                         GeneratedYangParser.OutputStatementContext ctx) {
+                                          GeneratedYangParser.OutputStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", ENTRY);
@@ -107,10 +110,10 @@
      * validations and updates the data model tree.
      *
      * @param listener listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processOutputExit(TreeWalkListener listener,
-                                        GeneratedYangParser.OutputStatementContext ctx) {
+                                         GeneratedYangParser.OutputStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, OUTPUT_DATA, "", EXIT);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java
index 17b0d57..c112ce0 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedJavaFileType.java
@@ -47,14 +47,16 @@
     public static final int GENERATE_INTERFACE_WITH_BUILDER = 15;
 
     /**
-     * Java class corresponding to typedef.
+     * Java interface corresponding to rpc.
      */
-    public static final int GENERATE_TYPEDEF_CLASS = 16;
+    public static final int GENERATE_RPC_INTERFACE = 16;
 
     /**
-     * Java class corresponding to union.
+     * Interface, class file and rpc.
      */
-    public static final int GENERATE_UNION_CLASS = 32;
+    public static final int GENERATE_MANAGER_WITH_RPC = 31;
+
+    // TODO RPC implementation to be integrated with notification.
 
     /**
      * Java class corresponding to YANG enumeration.
@@ -62,6 +64,16 @@
     public static final int GENERATE_ENUM_CLASS = 64;
 
     /**
+     * Java class corresponding to typedef.
+     */
+    public static final int GENERATE_TYPEDEF_CLASS = 1024;
+
+    /**
+     * Java class corresponding to union.
+     */
+    public static final int GENERATE_UNION_CLASS = 2048;
+
+    /**
      * Creates an instance of generate java file type.
      */
     private GeneratedJavaFileType() {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
index f64579b..e9e84bb 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/GeneratedTempFileType.java
@@ -79,7 +79,7 @@
     /**
      * From string implementation of class.
      */
-    public static final int UNION_FROM_STRING_IMPL_MASK = 2048;
+    public static final int FROM_STRING_IMPL_MASK = 2048;
 
     /**
      * Enum implementation of class.
@@ -87,6 +87,11 @@
     public static final int ENUM_IMPL_MASK = 4096;
 
     /**
+     * Rpc implementation of class.
+     */
+    public static final int RPC_IMPL_MASK = 8192;
+
+    /**
      * Creates an instance of generated temp file type.
      */
     private GeneratedTempFileType() {
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
index 44e8ab2..f50f84a 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaAttributeInfo.java
@@ -127,11 +127,11 @@
      * Creates an attribute info object corresponding to the passed enumeration attribute
      * information and return it.
      *
-     * @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 attribute name
      * @return AttributeInfo attribute details required to add in temporary
-     *         files
+     * files
      */
     public static JavaAttributeInfo getAttributeInfoOfEnumAttribute(YangNode curNode, String attributeName) {
 
@@ -146,6 +146,7 @@
 
         return getAttributeInfoForTheData(qualifiedTypeInfo, attributeName, null, curNode, false);
     }
+
     /**
      * Returns the data type info of attribute.
      *
@@ -302,6 +303,30 @@
     }
 
     /**
+     * Creates an attribute info object corresponding to a data model node and
+     * return it.
+     *
+     * @param parentNode  parent node in which the current node is an attribute
+     * @param isListNode  is the current added attribute needs to be a list
+     * @param curNodeName 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 parentNode, boolean isListNode,
+                                                                  String curNodeName) {
+
+        /*
+         * Get the import info corresponding to the attribute for import in
+         * generated java files or qualified access
+         */
+        JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(parentNode,
+                curNodeName, isListNode);
+
+        return getAttributeInfoForTheData(qualifiedTypeInfo, curNodeName, null, parentNode, isListNode);
+    }
+
+
+    /**
      * Returns java attribute info.
      *
      * @param importInfo      java qualified type info
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
index cc73ad4..77170dc 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/JavaQualifiedTypeInfo.java
@@ -169,7 +169,7 @@
     }
 
     /**
-     * Get the java qualified type information for the wrapper classes.
+     * Returns the java qualified type information for the wrapper classes.
      *
      * @param referredTypesAttrInfo attribute of referred type
      * @return return the import info for this attribute
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
index efc106e..cc52daa 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
@@ -21,7 +21,6 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
-
 import org.onosproject.yangutils.datamodel.HasType;
 import org.onosproject.yangutils.datamodel.YangEnum;
 import org.onosproject.yangutils.datamodel.YangEnumeration;
@@ -36,6 +35,7 @@
 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_ENUM_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_RPC_INTERFACE;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
@@ -45,14 +45,15 @@
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_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.OF_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_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.GeneratedTempFileType.UNION_FROM_STRING_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoOfEnumAttribute;
 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoOfLeaf;
 import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getAttributeInfoOfType;
@@ -66,6 +67,7 @@
 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateEnumClassFile;
 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.generateRpcInterfaceFile;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateTypeDefClassFile;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGenerator.generateUnionClassFile;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getFileObject;
@@ -85,6 +87,7 @@
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethod;
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOfMethodStringAndJavaDoc;
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getOverRideString;
+import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getRpcStringMethod;
 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;
@@ -109,9 +112,10 @@
 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.createPackage;
 import static org.onosproject.yangutils.utils.io.impl.FileSystemUtil.readAppendFile;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.generateJavaDocForRpc;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.clean;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.mergeJavaFiles;
@@ -226,7 +230,7 @@
     /**
      * File name for from string method.
      */
-    private static final String UNION_FROM_STRING_METHOD_FILE_NAME = "UnionFromString";
+    private static final String FROM_STRING_METHOD_FILE_NAME = "FromString";
 
     /**
      * File name for interface java file name suffix.
@@ -259,6 +263,16 @@
     private static final String ENUM_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING;
 
     /**
+     * File name for rpc method.
+     */
+    private static final String RPC_FILE_NAME = "Rpc";
+
+    /**
+     * File name for generated class file for special type like union, typedef suffix.
+     */
+    private static final String RPC_INTERFACE_FILE_NAME_SUFFIX = "Service";
+
+    /**
      * File name for generated class file for special type like union, typedef suffix.
      */
     private static final String UNION_TYPE_CLASS_FILE_NAME_SUFFIX = EMPTY_STRING;
@@ -354,9 +368,19 @@
     private File constructorForTypeTempFileHandle;
 
     /**
-     * Temporary file handle for union's from string method of class.
+     * Temporary file handle for from string method of class.
      */
-    private File unionFromStringImplTempFileHandle;
+    private File fromStringImplTempFileHandle;
+
+    /**
+     * Temporary file handle for rpc interface.
+     */
+    private File rpcInterfaceImplTempFileHandle;
+
+    /**
+     * Java file handle for rpc interface file.
+     */
+    private File rpcInterfaceJavaFileHandle;
 
     /**
      * Java attribute info.
@@ -439,6 +463,10 @@
             generatedTempFiles |= TO_STRING_IMPL_MASK;
         }
 
+        if ((genFileType & GENERATE_RPC_INTERFACE) != 0) {
+            generatedTempFiles |= RPC_IMPL_MASK;
+        }
+
         /**
          * Initialize getterImpl, attributes,  hash code, equals and
          * to strings when generation file type matches to typeDef class mask.
@@ -451,11 +479,12 @@
             generatedTempFiles |= TO_STRING_IMPL_MASK;
             generatedTempFiles |= OF_STRING_IMPL_MASK;
             generatedTempFiles |= CONSTRUCTOR_FOR_TYPE_MASK;
+            generatedTempFiles |= FROM_STRING_IMPL_MASK;
         }
 
         /**
          * Initialize getterImpl, attributes, hash code, equals, of string,
-         * constructor, union's to string, union's from string when generation
+         * constructor, union's to string, from string when generation
          * file type matches to union class mask.
          */
         if ((genFileType & GENERATE_UNION_CLASS) != 0) {
@@ -466,7 +495,7 @@
             generatedTempFiles |= OF_STRING_IMPL_MASK;
             generatedTempFiles |= CONSTRUCTOR_FOR_TYPE_MASK;
             generatedTempFiles |= TO_STRING_IMPL_MASK;
-            generatedTempFiles |= UNION_FROM_STRING_IMPL_MASK;
+            generatedTempFiles |= FROM_STRING_IMPL_MASK;
         }
         /**
          * Initialize enum when generation file type matches to enum class mask.
@@ -523,8 +552,12 @@
             setConstructorForTypeTempFileHandle(getTemporaryFileHandle(CONSTRUCTOR_FOR_TYPE_FILE_NAME));
         }
 
-        if ((generatedTempFiles & UNION_FROM_STRING_IMPL_MASK) != 0) {
-            setUnionFromStringImplTempFileHandle(getTemporaryFileHandle(UNION_FROM_STRING_METHOD_FILE_NAME));
+        if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) {
+            setFromStringImplTempFileHandle(getTemporaryFileHandle(FROM_STRING_METHOD_FILE_NAME));
+        }
+
+        if ((generatedTempFiles & RPC_IMPL_MASK) != 0) {
+            setRpcInterfaceImplTempFileHandle(getTemporaryFileHandle(RPC_FILE_NAME));
         }
     }
 
@@ -800,6 +833,42 @@
     }
 
     /**
+     * Returns rpc method's temporary file handle.
+     *
+     * @return temporary file handle
+     */
+    public File getRpcInterfaceImplTempFileHandle() {
+        return rpcInterfaceImplTempFileHandle;
+    }
+
+    /**
+     * Sets rpc method's temporary file handle.
+     *
+     * @param rpcInterfaceImplTempFileHandle file handle for to rpc method
+     */
+    public void setRpcInterfaceImplTempFileHandle(File rpcInterfaceImplTempFileHandle) {
+        this.rpcInterfaceImplTempFileHandle = rpcInterfaceImplTempFileHandle;
+    }
+
+    /**
+     * Returns rpc method's java file handle.
+     *
+     * @return java file handle
+     */
+    public File getRpcInterfaceJavaFileHandle() {
+        return rpcInterfaceJavaFileHandle;
+    }
+
+    /**
+     * Sets rpc method's java file handle.
+     *
+     * @param rpcInterfaceJavaFileHandle file handle for to rpc method
+     */
+    public void setRpcInterfaceJavaFileHandle(File rpcInterfaceJavaFileHandle) {
+        this.rpcInterfaceJavaFileHandle = rpcInterfaceJavaFileHandle;
+    }
+
+    /**
      * Returns to string method's temporary file handle.
      *
      * @return temporary file handle
@@ -873,21 +942,21 @@
     }
 
     /**
-     * Returns union's from string method's temporary file handle.
+     * Returns from string method's temporary file handle.
      *
-     * @return union's from string method's temporary file handle
+     * @return from string method's temporary file handle
      */
-    public File getUnionFromStringImplTempFileHandle() {
-        return unionFromStringImplTempFileHandle;
+    public File getFromStringImplTempFileHandle() {
+        return fromStringImplTempFileHandle;
     }
 
     /**
-     * Sets union's from string method's temporary file handle.
+     * Sets from string method's temporary file handle.
      *
-     * @param unionFromStringImplTempFileHandle union's from string method's temporary file handle
+     * @param fromStringImplTempFileHandle from string method's temporary file handle
      */
-    private void setUnionFromStringImplTempFileHandle(File unionFromStringImplTempFileHandle) {
-        this.unionFromStringImplTempFileHandle = unionFromStringImplTempFileHandle;
+    private void setFromStringImplTempFileHandle(File fromStringImplTempFileHandle) {
+        this.fromStringImplTempFileHandle = fromStringImplTempFileHandle;
     }
 
     /**
@@ -1158,13 +1227,35 @@
      * @param fromStringAttributeInfo from string attribute info
      * @throws IOException when fails to append to temporary file
      */
-    private void addUnionFromStringMethod(JavaAttributeInfo javaAttributeInfo,
-                                          JavaAttributeInfo fromStringAttributeInfo) throws IOException {
-        appendToFile(getUnionFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo,
+    private void addFromStringMethod(JavaAttributeInfo javaAttributeInfo,
+                                     JavaAttributeInfo fromStringAttributeInfo) throws IOException {
+        appendToFile(getFromStringImplTempFileHandle(), getFromStringMethod(javaAttributeInfo,
                 fromStringAttributeInfo) + NEW_LINE);
     }
 
     /**
+     * Adds rpc string information to applicable temp file.
+     *
+     * @param javaAttributeInfoOfInput  rpc's input node attribute info
+     * @param javaAttributeInfoOfOutput rpc's output node attribute info
+     * @param rpcName                   name of the rpc function
+     * @throws IOException IO operation fail
+     */
+    private void addRpcString(JavaAttributeInfo javaAttributeInfoOfInput, JavaAttributeInfo javaAttributeInfoOfOutput,
+                              String rpcName) throws IOException {
+        String rpcInput = "";
+        String rpcOutput = "void";
+        if (javaAttributeInfoOfInput != null) {
+            rpcInput = javaAttributeInfoOfInput.getAttributeName();
+        }
+        if (javaAttributeInfoOfOutput != null) {
+            rpcOutput = javaAttributeInfoOfOutput.getAttributeName();
+        }
+        appendToFile(getRpcInterfaceImplTempFileHandle(), generateJavaDocForRpc(rpcName, rpcInput, rpcOutput) +
+                getRpcStringMethod(rpcName, rpcInput, rpcOutput) + NEW_LINE);
+    }
+
+    /**
      * Returns a temporary file handle for the specific file type.
      *
      * @param fileName file name
@@ -1416,13 +1507,29 @@
 
         JavaAttributeInfo fromStringAttributeInfo = getFromStringAttributeInfo(hasType, javaAttributeInfo);
 
-        if ((generatedTempFiles & UNION_FROM_STRING_IMPL_MASK) != 0) {
-            addUnionFromStringMethod(javaAttributeInfo, fromStringAttributeInfo);
+        if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) {
+            addFromStringMethod(javaAttributeInfo, fromStringAttributeInfo);
         }
         addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo);
     }
 
     /**
+     * Adds the JAVA rpc snippet information.
+     *
+     * @param javaAttributeInfoOfInput  rpc's input node attribute info
+     * @param javaAttributeInfoOfOutput rpc's output node attribute info
+     * @param rpcName                   name of the rpc function
+     * @throws IOException IO operation fail
+     */
+    public void addJavaSnippetInfoToApplicableTempFiles(JavaAttributeInfo javaAttributeInfoOfInput,
+                                                        JavaAttributeInfo javaAttributeInfoOfOutput,
+                                                        String rpcName) throws IOException {
+        if ((generatedTempFiles & RPC_IMPL_MASK) != 0) {
+            addRpcString(javaAttributeInfoOfInput, javaAttributeInfoOfOutput, rpcName);
+        }
+    }
+
+    /**
      * Adds the new attribute info to the target generated temporary files.
      *
      * @param newAttrInfo the attribute info that needs to be added to temporary
@@ -1642,6 +1749,14 @@
         }
 
         /**
+         * Creates rpc interface file.
+         */
+        if ((fileType & GENERATE_RPC_INTERFACE) != 0) {
+            setRpcInterfaceJavaFileHandle(getJavaFileHandle(getJavaClassName(RPC_INTERFACE_FILE_NAME_SUFFIX)));
+            setRpcInterfaceJavaFileHandle(generateRpcInterfaceFile(getRpcInterfaceJavaFileHandle(), curNode, imports));
+        }
+
+        /**
          * Close all the file handles.
          */
         close(false);
@@ -1681,6 +1796,9 @@
         if ((generatedJavaFiles & GENERATE_UNION_CLASS) != 0) {
             closeFile(getTypeClassJavaFileHandle(), isError);
         }
+        if ((generatedJavaFiles & GENERATE_RPC_INTERFACE) != 0) {
+            closeFile(getRpcInterfaceJavaFileHandle(), isError);
+        }
 
         /**
          * Close all temporary file handles and delete the files.
@@ -1721,11 +1839,13 @@
         if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) {
             closeFile(getOfStringImplTempFileHandle(), true);
         }
-        if ((generatedTempFiles & UNION_FROM_STRING_IMPL_MASK) != 0) {
-            closeFile(getUnionFromStringImplTempFileHandle(), true);
+        if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) {
+            closeFile(getFromStringImplTempFileHandle(), true);
+        }
+        if ((generatedTempFiles & RPC_IMPL_MASK) != 0) {
+            closeFile(getRpcInterfaceImplTempFileHandle(), true);
         }
         clean(getTempDirPath());
         generatedTempFiles = 0;
     }
-
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java
index fe99500..ccb82c6 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaEnumeration.java
@@ -17,7 +17,6 @@
 package org.onosproject.yangutils.translator.tojava.javamodel;
 
 import java.io.IOException;
-
 import org.onosproject.yangutils.datamodel.YangEnumeration;
 import org.onosproject.yangutils.translator.exception.TranslatorException;
 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
@@ -27,7 +26,7 @@
 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_ENUM_CLASS;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfType;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
 
 /**
  * Represents YANG java enumeration information extended to support java code generation.
@@ -101,7 +100,7 @@
      * Sets the data of java imports to be included in generated file.
      *
      * @param javaImportData data of java imports to be included in generated
-     *            file
+     *                       file
      */
     @Override
     public void setJavaImportData(JavaImportData javaImportData) {
@@ -140,7 +139,7 @@
      */
     @Override
     public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
-        generateCodeOfType(this, yangPlugin, false);
+        generateCodeOfNode(this, yangPlugin);
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
index 96cbb47..14e2cdf 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaInput.java
@@ -68,7 +68,7 @@
     @Override
     public JavaFileInfo getJavaFileInfo() {
         if (javaFileInfo == null) {
-            throw new TranslatorException("Missing java info in java datamodel node");
+            throw new TranslatorException("missing java info in java datamodel node");
         }
         return javaFileInfo;
     }
@@ -97,7 +97,7 @@
      * Sets the data of java imports to be included in generated file.
      *
      * @param javaImportData data of java imports to be included in generated
-     *            file
+     *                       file
      */
     @Override
     public void setJavaImportData(JavaImportData javaImportData) {
@@ -133,7 +133,7 @@
      */
     @Override
     public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
-        generateCodeOfNode(this, yangPlugin, false);
+        generateCodeOfNode(this, yangPlugin);
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
index 8895da2..7670b31 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaModule.java
@@ -25,7 +25,7 @@
 import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils;
 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 
-import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_MANAGER_WITH_RPC;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
 
 /**
@@ -57,7 +57,7 @@
         super();
         setJavaFileInfo(new JavaFileInfo());
         setJavaImportData(new JavaImportData());
-        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC);
     }
 
     /**
@@ -97,7 +97,7 @@
      * Sets the data of java imports to be included in generated file.
      *
      * @param javaImportData data of java imports to be included in generated
-     *            file
+     *                       file
      */
     @Override
     public void setJavaImportData(JavaImportData javaImportData) {
@@ -141,6 +141,6 @@
      */
     @Override
     public void generateCodeExit() throws IOException {
-        getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_INTERFACE_WITH_BUILDER, this);
+        getTempJavaCodeFragmentFiles().generateJavaFile(GENERATE_MANAGER_WITH_RPC, this);
     }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
index 7508dd4..db29d57 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaOutput.java
@@ -68,7 +68,7 @@
     @Override
     public JavaFileInfo getJavaFileInfo() {
         if (javaFileInfo == null) {
-            throw new TranslatorException("Missing java info in java datamodel node");
+            throw new TranslatorException("missing java info in java datamodel node");
         }
         return javaFileInfo;
     }
@@ -97,7 +97,7 @@
      * Sets the data of java imports to be included in generated file.
      *
      * @param javaImportData data of java imports to be included in generated
-     *            file
+     *                       file
      */
     @Override
     public void setJavaImportData(JavaImportData javaImportData) {
@@ -133,7 +133,7 @@
      */
     @Override
     public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
-        generateCodeOfNode(this, yangPlugin, false);
+        generateCodeOfNode(this, yangPlugin);
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
index a4ce6bb..1f138ea 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaRpc.java
@@ -17,40 +17,132 @@
 package org.onosproject.yangutils.translator.tojava.javamodel;
 
 import java.io.IOException;
+import org.onosproject.yangutils.datamodel.HasRpcNotification;
+import org.onosproject.yangutils.datamodel.YangInput;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangOutput;
 import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.translator.exception.TranslatorException;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
+import org.onosproject.yangutils.translator.tojava.HasTempJavaCodeFragmentFiles;
+import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
 import org.onosproject.yangutils.translator.tojava.JavaCodeGenerator;
+import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 
+import static org.onosproject.yangutils.translator.tojava.JavaAttributeInfo.getCurNodeAsAttributeInParent;
+import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getParentNodeInGenCode;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.updatePackageInfo;
+
 /**
  * Represents rpc information extended to support java code generation.
  */
-public class YangJavaRpc extends YangRpc implements JavaCodeGenerator {
+public class YangJavaRpc extends YangRpc implements JavaCodeGenerator, HasJavaFileInfo {
 
     /**
-     * Creates an instance of java Rpc.
+     * Contains the information of the java file being generated.
+     */
+    private JavaFileInfo javaFileInfo;
+
+    /**
+     * Creates an instance of YANG java rpc.
      */
     public YangJavaRpc() {
+        super();
+        setJavaFileInfo(new JavaFileInfo());
     }
 
     /**
      * Prepares the information for java code generation corresponding to YANG
-     * RPC info.
+     * rpc info.
      *
      * @param yangPlugin YANG plugin config
-     * @throws IOException IO operation fail
+     * @throws IOException IO operations fails
      */
     @Override
     public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
-          // TODO
+
+        if (!(this instanceof YangNode)) {
+            // TODO:throw exception
+        }
+
+        // Add package information for rpc and create corresponding folder.
+        updatePackageInfo(this, yangPlugin);
+
+        // Get the parent module/sub-module.
+        YangNode parent = getParentNodeInGenCode((YangNode) this);
+
+        // Parent should be holder of rpc or notification.
+        if (!(parent instanceof HasRpcNotification)) {
+            throw new TranslatorException("parent node of rpc can only be module or sub-module");
+        }
+
+        /*
+         * Create attribute info for input and output of rpc and add it to the
+         * parent import list.
+         */
+
+        JavaAttributeInfo javaAttributeInfoOfInput = null;
+        JavaAttributeInfo javaAttributeInfoOfOutput = null;
+
+        // Get the child input and output node and obtain create java attribute info.
+        YangNode yangNode = this.getChild();
+        while (yangNode != null) {
+            if (yangNode instanceof YangInput) {
+                javaAttributeInfoOfInput = getCurNodeAsAttributeInParent(parent, false, yangNode.getName());
+            } else if (yangNode instanceof YangOutput) {
+                javaAttributeInfoOfOutput = getCurNodeAsAttributeInParent(parent, false, yangNode.getName());
+            } else {
+                // TODO throw exception
+            }
+            yangNode = yangNode.getNextSibling();
+        }
+
+        if (!(parent instanceof HasTempJavaCodeFragmentFiles)) {
+            throw new TranslatorException("missing parent temp file handle");
+        }
+
+        /*
+         * Add the rpc information to the parent's service temp file.
+         */
+        ((HasTempJavaCodeFragmentFiles) parent)
+                .getTempJavaCodeFragmentFiles()
+                .addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfoOfInput, javaAttributeInfoOfOutput,
+                        ((YangNode) this).getName());
     }
 
     /**
-     * Creates a java file using the YANG RPC info.
+     * Creates a java file using the YANG rpc info.
      *
-     * @throws IOException IO operation fail
+     * @throws IOException IO operations fails
      */
     @Override
     public void generateCodeExit() throws IOException {
-          // TODO
+        // No file will be generated during RPC exit.
+    }
+
+    /**
+     * Returns the generated java file information.
+     *
+     * @return generated java file information
+     */
+    @Override
+    public JavaFileInfo getJavaFileInfo() {
+
+        if (javaFileInfo == null) {
+            throw new TranslatorException("missing java info in java datamodel node");
+        }
+        return javaFileInfo;
+    }
+
+    /**
+     * Sets the java file info object.
+     *
+     * @param javaInfo java file info object
+     */
+    @Override
+    public void setJavaFileInfo(JavaFileInfo javaInfo) {
+        javaFileInfo = javaInfo;
     }
 }
+
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
index d31961d..8bf7592 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaSubModule.java
@@ -26,7 +26,7 @@
 import org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils;
 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 
-import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_INTERFACE_WITH_BUILDER;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_MANAGER_WITH_RPC;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getRootPackage;
 
 /**
@@ -58,7 +58,7 @@
         super();
         setJavaFileInfo(new JavaFileInfo());
         setJavaImportData(new JavaImportData());
-        getJavaFileInfo().setGeneratedFileTypes(GENERATE_INTERFACE_WITH_BUILDER);
+        getJavaFileInfo().setGeneratedFileTypes(GENERATE_MANAGER_WITH_RPC);
     }
 
     /**
@@ -98,7 +98,7 @@
      * Sets the data of java imports to be included in generated file.
      *
      * @param javaImportData data of java imports to be included in generated
-     *            file
+     *                       file
      */
     @Override
     public void setJavaImportData(JavaImportData javaImportData) {
@@ -129,7 +129,7 @@
      * Returns 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
+     *                      belongs
      * @return the name space string of the module.
      */
     private String getNameSpaceFromModule(YangBelongsTo belongsToInfo) {
@@ -138,7 +138,7 @@
     }
 
     /**
-     * Prepare the information for java code generation corresponding to YANG
+     * Prepares the information for java code generation corresponding to YANG
      * submodule info.
      *
      * @param yangPlugin YANG plugin config
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
index 7e32f08..b7efb5f 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaTypeDef.java
@@ -25,7 +25,7 @@
 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfType;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
 
 /**
  * Represents type define information extended to support java code generation.
@@ -133,7 +133,7 @@
      */
     @Override
     public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
-        generateCodeOfType(this, yangPlugin, false);
+        generateCodeOfNode(this, yangPlugin, false);
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
index 8280184..7af19c6 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/javamodel/YangJavaUnion.java
@@ -24,7 +24,7 @@
 import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
-import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfType;
+import static org.onosproject.yangutils.translator.tojava.utils.YangJavaModelUtils.generateCodeOfNode;
 
 /**
  * Represents union information extended to support java code generation.
@@ -135,7 +135,7 @@
      */
     @Override
     public void generateCodeEntry(YangPluginConfig yangPlugin) throws IOException {
-        generateCodeOfType(this, yangPlugin, false);
+        generateCodeOfNode(this, yangPlugin);
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
index 0db41c9..ec58b26 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/ClassDefinitionGenerator.java
@@ -19,6 +19,7 @@
 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_ENUM_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_RPC_INTERFACE;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
@@ -63,7 +64,7 @@
     public static String generateClassDefinition(int genFileTypes, String yangName) {
 
         /**
-         * based on the file type and the YANG name of the file, generate the
+         * Based on the file type and the YANG name of the file, generate the
          * class / interface definition start.
          */
         if ((genFileTypes & INTERFACE_MASK) != 0) {
@@ -80,6 +81,8 @@
             return getTypeClassDefinition(yangName);
         } else if ((genFileTypes & GENERATE_ENUM_CLASS) != 0) {
             return getEnumClassDefinition(yangName);
+        } else if ((genFileTypes & GENERATE_RPC_INTERFACE) != 0) {
+            return getRpcInterfaceDefinition(yangName);
         }
         return null;
     }
@@ -88,7 +91,7 @@
      * Returns enum file class definition.
      *
      * @param yangName class name
-     * @return enum file class definiton
+     * @return enum file class definition
      */
     private static String getEnumClassDefinition(String yangName) {
         return PUBLIC + SPACE + ENUM + SPACE + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
@@ -155,4 +158,14 @@
     private static String getTypeClassDefinition(String yangName) {
         return PUBLIC + SPACE + FINAL + SPACE + CLASS + SPACE + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
     }
+
+    /**
+     * Returns rpc file interface definition.
+     *
+     * @param yangName file name
+     * @return definition
+     */
+    private static String getRpcInterfaceDefinition(String yangName) {
+        return INTERFACE + SPACE + yangName + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index aa208e5..ff548fc 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -28,6 +28,7 @@
 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_ENUM_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_RPC_INTERFACE;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
@@ -37,14 +38,15 @@
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.CONSTRUCTOR_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.ENUM_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.EQUALS_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_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.OF_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_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.GeneratedTempFileType.UNION_FROM_STRING_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getAugmentedInfoAttribute;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getDataFromTempFileHandle;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaFileGeneratorUtils.getEnumsValueAttribute;
@@ -78,9 +80,10 @@
 import static org.onosproject.yangutils.utils.UtilConstants.PRIVATE;
 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
+import static org.onosproject.yangutils.utils.UtilConstants.SERVICE_METHOD_STRING;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.partString;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
@@ -180,7 +183,7 @@
     }
 
     /**
-     * Return generated builder interface file for current node.
+     * Returns generated builder interface file for current node.
      *
      * @param file          file
      * @param curNode       current YANG node
@@ -468,6 +471,13 @@
             methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK, curNode)
                     + getToStringMethodClose());
 
+            /**
+             * From string method.
+             */
+            methods.add(getFromStringMethodSignature(className)
+                    + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, curNode)
+                    + getFromStringMethodClose());
+
         } catch (IOException e) {
             throw new IOException("No data found in temporary java code fragment files for " + className
                     + " while type def class file generation");
@@ -557,7 +567,7 @@
              * From string method.
              */
             methods.add(getFromStringMethodSignature(className)
-                    + getDataFromTempFileHandle(UNION_FROM_STRING_IMPL_MASK, curNode)
+                    + getDataFromTempFileHandle(FROM_STRING_IMPL_MASK, curNode)
                     + getFromStringMethodClose());
 
         } catch (IOException e) {
@@ -576,11 +586,11 @@
     /**
      * Generates class file for type enum.
      *
-     * @param file generated file
+     * @param file    generated file
      * @param curNode current YANG node
      * @return class file for type enum
      * @throws IOException when fails to generate class file
-    */
+     */
     public static File generateEnumClassFile(File file, YangNode curNode) throws IOException {
 
         JavaFileInfo javaFileInfo = ((HasJavaFileInfo) curNode).getJavaFileInfo();
@@ -624,4 +634,44 @@
 
         return file;
     }
+
+    /**
+     * Generates interface file for rpc.
+     *
+     * @param file    generated file
+     * @param curNode current YANG node
+     * @param imports imports for file
+     * @return type def class file
+     * @throws IOException when fails to generate class file
+     */
+    public static File generateRpcInterfaceFile(File file, YangNode curNode, List<String> imports) throws IOException {
+
+        JavaFileInfo javaFileInfo = ((HasJavaFileInfo) curNode).getJavaFileInfo();
+
+        String className = getCaptialCase(javaFileInfo.getJavaName()) + SERVICE_METHOD_STRING;
+        String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
+
+        initiateJavaFileGeneration(file, className, GENERATE_RPC_INTERFACE, imports, path);
+
+        List<String> methods = new ArrayList<>();
+
+        try {
+
+            /**
+             * Rpc methods
+             */
+            methods.add(getDataFromTempFileHandle(RPC_IMPL_MASK, curNode));
+
+        } catch (IOException e) {
+            throw new IOException("No data found in temporary java code fragment files for " + className
+                    + " while rpc class file generation");
+        }
+
+        for (String method : methods) {
+            insertDataIntoJavaFile(file, method);
+        }
+        insertDataIntoJavaFile(file, CLOSE_CURLY_BRACKET + NEW_LINE);
+
+        return file;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
index 5828e03..cb1263f 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGeneratorUtils.java
@@ -29,6 +29,7 @@
 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_ENUM_CLASS;
+import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_RPC_INTERFACE;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_TYPEDEF_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.GENERATE_UNION_CLASS;
 import static org.onosproject.yangutils.translator.tojava.GeneratedJavaFileType.IMPL_CLASS_MASK;
@@ -42,10 +43,11 @@
 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.OF_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.RPC_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.GeneratedTempFileType.UNION_FROM_STRING_IMPL_MASK;
+import static org.onosproject.yangutils.translator.tojava.GeneratedTempFileType.FROM_STRING_IMPL_MASK;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getJavaClassDefStart;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getJavaPackageFromPackagePath;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getSmallCase;
@@ -58,12 +60,13 @@
 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
 import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_CLASS;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILDER_INTERFACE;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.ENUM_CLASS;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.IMPL_CLASS;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.INTERFACE;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.RPC_INTERFACE;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.insertDataIntoJavaFile;
 
 /**
@@ -138,12 +141,15 @@
         } else if ((generatedTempFiles & OF_STRING_IMPL_MASK) != 0) {
             return tempJavaCodeFragmentFiles
                     .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getOfStringImplTempFileHandle());
-        } else if ((generatedTempFiles & UNION_FROM_STRING_IMPL_MASK) != 0) {
+        } else if ((generatedTempFiles & FROM_STRING_IMPL_MASK) != 0) {
             return tempJavaCodeFragmentFiles
-                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getUnionFromStringImplTempFileHandle());
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getFromStringImplTempFileHandle());
         } else if ((generatedTempFiles & ENUM_IMPL_MASK) != 0) {
             return tempJavaCodeFragmentFiles
                     .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getEnumClassTempFileHandle());
+        } else if ((generatedTempFiles & RPC_IMPL_MASK) != 0) {
+            return tempJavaCodeFragmentFiles
+                    .getTemporaryDataFromFileHandle(tempJavaCodeFragmentFiles.getRpcInterfaceImplTempFileHandle());
         }
         return null;
     }
@@ -203,6 +209,9 @@
         } else if ((type & GENERATE_ENUM_CLASS) != 0) {
             appendHeaderContents(file, pkgString, importsList);
             write(file, fileName, type, ENUM_CLASS);
+        } else if ((type & GENERATE_RPC_INTERFACE) != 0) {
+            appendHeaderContents(file, pkgString, importsList);
+            write(file, fileName, type, RPC_INTERFACE);
         }
     }
 
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 309ed22..03be712 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
@@ -72,6 +72,7 @@
 import static org.onosproject.yangutils.utils.UtilConstants.PUBLIC;
 import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
 import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
+import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_VAR_NAME;
 import static org.onosproject.yangutils.utils.UtilConstants.SEMI_COLAN;
 import static org.onosproject.yangutils.utils.UtilConstants.SET_METHOD_PREFIX;
 import static org.onosproject.yangutils.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION;
@@ -87,15 +88,15 @@
 import static org.onosproject.yangutils.utils.UtilConstants.TWELVE_SPACE_INDENTATION;
 import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
 import static org.onosproject.yangutils.utils.UtilConstants.VOID;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.BUILD_METHOD;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.CONSTRUCTOR;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.DEFAULT_CONSTRUCTOR;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.FROM_METHOD;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.GETTER_METHOD;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.OF_METHOD;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.SETTER_METHOD;
 import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.TYPE_CONSTRUCTOR;
-import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.JavaDocType.UNION_FROM_METHOD;
+import static org.onosproject.yangutils.utils.io.impl.JavaDocGen.getJavaDoc;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
 
 /**
@@ -425,6 +426,24 @@
     }
 
     /**
+     * Returns the rpc strings for service interface.
+     *
+     * @param rpcName    name of the rpc
+     * @param inputName  name of input
+     * @param outputName name of output
+     * @return rpc method string
+     */
+    public static String getRpcStringMethod(String rpcName, String inputName, String outputName) {
+
+        rpcName = getSmallCase(getCamelCase(rpcName, null));
+        inputName = getCaptialCase(inputName);
+        outputName = getCaptialCase(outputName);
+
+        return FOUR_SPACE_INDENTATION + PUBLIC + SPACE + outputName + SPACE + rpcName + OPEN_PARENTHESIS
+                + inputName + SPACE + RPC_INPUT_VAR_NAME + CLOSE_PARENTHESIS + SEMI_COLAN;
+    }
+
+    /**
      * Returns the build method strings for class file.
      *
      * @param yangName class name
@@ -499,7 +518,7 @@
      * @return from string method's open string
      */
     public static String getFromStringMethodSignature(String className) {
-        return getJavaDoc(UNION_FROM_METHOD, className, false) + FOUR_SPACE_INDENTATION + PUBLIC + SPACE
+        return getJavaDoc(FROM_METHOD, className, false) + FOUR_SPACE_INDENTATION + PUBLIC + SPACE
                 + className + SPACE + FROM_STRING_METHOD_NAME + OPEN_PARENTHESIS + STRING_DATA_TYPE + SPACE
                 + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE;
     }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
index c28271b..cd6a7cd 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/utils/YangJavaModelUtils.java
@@ -28,6 +28,7 @@
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.datamodel.YangNotification;
 import org.onosproject.yangutils.datamodel.YangOutput;
+import org.onosproject.yangutils.translator.tojava.HasJavaFileInfo;
 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFiles;
 import org.onosproject.yangutils.translator.tojava.javamodel.JavaCodeGeneratorInfo;
 import org.onosproject.yangutils.translator.tojava.javamodel.YangJavaEnumeration;
@@ -54,19 +55,19 @@
     /**
      * Updates YANG java file package information.
      *
-     * @param javaCodeGeneratorInfo YANG java file info node
-     * @param yangPlugin            YANG plugin config
+     * @param hasJavaFileInfo YANG java file info node
+     * @param yangPlugin      YANG plugin config
      * @throws IOException IO operations fails
      */
-    private static void updatePackageInfo(JavaCodeGeneratorInfo javaCodeGeneratorInfo, YangPluginConfig yangPlugin)
+    public static void updatePackageInfo(HasJavaFileInfo hasJavaFileInfo, YangPluginConfig yangPlugin)
             throws IOException {
-        javaCodeGeneratorInfo.getJavaFileInfo()
+        hasJavaFileInfo.getJavaFileInfo()
                 .setJavaName(getCaptialCase(
-                        getCamelCase(((YangNode) javaCodeGeneratorInfo).getName(), yangPlugin.getConflictResolver())));
-        javaCodeGeneratorInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) javaCodeGeneratorInfo));
-        javaCodeGeneratorInfo.getJavaFileInfo().setPackageFilePath(
-                getPackageDirPathFromJavaJPackage(javaCodeGeneratorInfo.getJavaFileInfo().getPackage()));
-        javaCodeGeneratorInfo.getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir());
+                        getCamelCase(((YangNode) hasJavaFileInfo).getName(), yangPlugin.getConflictResolver())));
+        hasJavaFileInfo.getJavaFileInfo().setPackage(getCurNodePackage((YangNode) hasJavaFileInfo));
+        hasJavaFileInfo.getJavaFileInfo().setPackageFilePath(
+                getPackageDirPathFromJavaJPackage(hasJavaFileInfo.getJavaFileInfo().getPackage()));
+        hasJavaFileInfo.getJavaFileInfo().setBaseCodeGenPath(yangPlugin.getCodeGenDir());
     }
 
     /**
@@ -155,7 +156,7 @@
         if (!(javaCodeGeneratorInfo instanceof YangNode)) {
             // TODO:throw exception
         }
-        updatePackageInfo(javaCodeGeneratorInfo, yangPlugin);
+        updatePackageInfo((HasJavaFileInfo) javaCodeGeneratorInfo, yangPlugin);
         generateTempFiles(javaCodeGeneratorInfo, yangPlugin.getCodeGenDir());
 
         javaCodeGeneratorInfo.getTempJavaCodeFragmentFiles()
@@ -182,15 +183,14 @@
      *
      * @param javaCodeGeneratorInfo YANG java file info node
      * @param yangPlugin            YANG plugin config
-     * @param isMultiInstance       flag to indicate whether it's a list
      * @throws IOException IO operations fails
      */
-    public static void generateCodeOfType(JavaCodeGeneratorInfo javaCodeGeneratorInfo, YangPluginConfig yangPlugin,
-                                          boolean isMultiInstance) throws IOException {
+    public static void generateCodeOfNode(JavaCodeGeneratorInfo javaCodeGeneratorInfo, YangPluginConfig yangPlugin)
+            throws IOException {
         if (!(javaCodeGeneratorInfo instanceof YangNode)) {
             // TODO:throw exception
         }
-        updatePackageInfo(javaCodeGeneratorInfo, yangPlugin);
+        updatePackageInfo((HasJavaFileInfo) javaCodeGeneratorInfo, yangPlugin);
         generateTempFiles(javaCodeGeneratorInfo, yangPlugin.getCodeGenDir());
     }
 
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index 4b9d7b5..def4cc9 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -138,6 +138,21 @@
     public static final String BUILDER_OBJECT = "builder object of ";
 
     /**
+     * JavaDocs's statement for rpc method.
+     */
+    public static final String JAVA_DOC_RPC = " * Service interface of ";
+
+    /**
+     * JavaDocs's statement for rpc's input string.
+     */
+    public static final String RPC_INPUT_STRING = "input of service interface ";
+
+    /**
+     * JavaDocs's statement for rpc's output string.
+     */
+    public static final String RPC_OUTPUT_STRING = "output of service interface ";
+
+    /**
      * Static attribute for new line.
      */
     public static final String NEW_LINE = "\n";
@@ -218,6 +233,11 @@
     public static final String INPUT = "input";
 
     /**
+     * Static attribute for output variable of rpc.
+     */
+    public static final String RPC_INPUT_VAR_NAME = "inputVar";
+
+    /**
      * Static attribute for new line.
      */
     public static final String EQUAL = "=";
@@ -723,6 +743,11 @@
     public static final String EXTEND = "extends";
 
     /**
+     * Static attribute for service interface suffix syntax.
+     */
+    public static final String SERVICE_METHOD_STRING = "Service";
+
+    /**
      * Static attribute for impl syntax.
      */
     public static final String IMPL = "Impl";
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
index 0ecaaa1..c793cd6 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/JavaDocGen.java
@@ -18,6 +18,8 @@
 
 import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
 
+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.utils.UtilConstants.BUILDER;
 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_CLASS_JAVA_DOC;
 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER_INTERFACE_JAVA_DOC;
@@ -40,6 +42,7 @@
 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_OF;
 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_PARAM;
 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_RETURN;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_RPC;
 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS;
 import static org.onosproject.yangutils.utils.UtilConstants.JAVA_DOC_SETTERS_COMMON;
 import static org.onosproject.yangutils.utils.UtilConstants.LIST;
@@ -49,6 +52,8 @@
 import static org.onosproject.yangutils.utils.UtilConstants.OF;
 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE_INFO_JAVADOC;
 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.RPC_INPUT_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.RPC_OUTPUT_STRING;
 import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
 import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
 import static org.onosproject.yangutils.utils.UtilConstants.VALUE;
@@ -100,6 +105,11 @@
         GETTER_METHOD,
 
         /**
+         * For rpc.
+         */
+        RPC_INTERFACE,
+
+        /**
          * For setters.
          */
         SETTER_METHOD,
@@ -125,9 +135,9 @@
         CONSTRUCTOR,
 
         /**
-         * For union's from method.
+         * For from method.
          */
-        UNION_FROM_METHOD,
+        FROM_METHOD,
 
         /**
          * For type constructor.
@@ -160,42 +170,60 @@
      */
     public static String getJavaDoc(JavaDocType type, String name, boolean isList) {
 
-        name = JavaIdentifierSyntax.getSmallCase(JavaIdentifierSyntax.getCamelCase(name, null));
-        String javaDoc;
-        if (type.equals(JavaDocType.IMPL_CLASS)) {
-            javaDoc = generateForImplClass(name);
-        } else if (type.equals(JavaDocType.BUILDER_CLASS)) {
-            javaDoc = generateForBuilderClass(name);
-        } else if (type.equals(JavaDocType.INTERFACE)) {
-            javaDoc = generateForInterface(name);
-        } else if (type.equals(JavaDocType.BUILDER_INTERFACE)) {
-            javaDoc = generateForBuilderInterface(name);
-        } else if (type.equals(JavaDocType.PACKAGE_INFO)) {
-            javaDoc = generateForPackage(name);
-        } else if (type.equals(JavaDocType.GETTER_METHOD)) {
-            javaDoc = generateForGetters(name, isList);
-        } else if (type.equals(JavaDocType.TYPE_DEF_SETTER_METHOD)) {
-            javaDoc = generateForTypeDefSetter(name);
-        } else if (type.equals(JavaDocType.SETTER_METHOD)) {
-            javaDoc = generateForSetters(name, isList);
-        } else if (type.equals(JavaDocType.OF_METHOD)) {
-            javaDoc = generateForOf(name);
-        } else if (type.equals(JavaDocType.DEFAULT_CONSTRUCTOR)) {
-            javaDoc = generateForDefaultConstructors(name);
-        } else if (type.equals(JavaDocType.BUILD_METHOD)) {
-            javaDoc = generateForBuild(name);
-        } else if (type.equals(JavaDocType.TYPE_CONSTRUCTOR)) {
-            javaDoc = generateForTypeConstructor(name);
-        } else if (type.equals(JavaDocType.UNION_FROM_METHOD)) {
-            javaDoc = generateForUnionFrom(name);
-        } else if (type.equals(JavaDocType.ENUM_CLASS)) {
-            javaDoc = generateForEnum(name);
-        } else if (type.equals(JavaDocType.ENUM_ATTRIBUTE)) {
-            javaDoc = generateForEnumAttr(name);
-        } else {
-            javaDoc = generateForConstructors(name);
+        name = JavaIdentifierSyntax.getSmallCase(getCamelCase(name, null));
+        switch (type) {
+            case IMPL_CLASS: {
+                return generateForImplClass(name);
+            }
+            case BUILDER_CLASS: {
+                return generateForBuilderClass(name);
+            }
+            case INTERFACE: {
+                return generateForInterface(name);
+            }
+            case BUILDER_INTERFACE: {
+                return generateForBuilderInterface(name);
+            }
+            case PACKAGE_INFO: {
+                return generateForPackage(name);
+            }
+            case GETTER_METHOD: {
+                return generateForGetters(name, isList);
+            }
+            case TYPE_DEF_SETTER_METHOD: {
+                return generateForTypeDefSetter(name);
+            }
+            case SETTER_METHOD: {
+                return generateForSetters(name, isList);
+            }
+            case OF_METHOD: {
+                return generateForOf(name);
+            }
+            case DEFAULT_CONSTRUCTOR: {
+                return generateForDefaultConstructors(name);
+            }
+            case BUILD_METHOD: {
+                return generateForBuild(name);
+            }
+            case TYPE_CONSTRUCTOR: {
+                return generateForTypeConstructor(name);
+            }
+            case FROM_METHOD: {
+                return generateForFromString(name);
+            }
+            case ENUM_CLASS: {
+                return generateForEnum(name);
+            }
+            case ENUM_ATTRIBUTE: {
+                return generateForEnumAttr(name);
+            }
+            case RPC_INTERFACE: {
+                return generateForRpcInterface(name);
+            }
+            default: {
+                return generateForConstructors(name);
+            }
         }
-        return javaDoc;
     }
 
     /**
@@ -210,6 +238,62 @@
     }
 
     /**
+     * Generates javaDocs for rpc method.
+     *
+     * @param rpcName    name of the rpc
+     * @param inputName  name of input
+     * @param outputName name of output
+     * @return javaDocs of rpc method
+     */
+    public static String generateJavaDocForRpc(String rpcName, String inputName, String outputName) {
+        rpcName = getCamelCase(rpcName, null);
+        inputName = getCaptialCase(inputName);
+        outputName = getCaptialCase(outputName);
+
+        return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_RPC
+                + rpcName + PERIOD + NEW_LINE + FOUR_SPACE_INDENTATION + NEW_LINE_ASTERISK
+                + getInputString(inputName, rpcName) + getOutputString(outputName, rpcName) + FOUR_SPACE_INDENTATION
+                + JAVA_DOC_END_LINE;
+    }
+
+    /**
+     * Returns output string of rpc.
+     *
+     * @param outputName name of output
+     * @param rpcName    name of rpc
+     * @return javaDocs for output string of rpc
+     */
+    private static String getOutputString(String outputName, String rpcName) {
+        return FOUR_SPACE_INDENTATION + JAVA_DOC_RETURN + outputName + SPACE + RPC_OUTPUT_STRING + rpcName + NEW_LINE;
+    }
+
+    /**
+     * Returns input string of rpc.
+     *
+     * @param inputName name of input
+     * @param rpcName   name of rpc
+     * @return javaDocs for input string of rpc
+     */
+    private static String getInputString(String inputName, String rpcName) {
+        if (inputName.equals("")) {
+            return null;
+        } else {
+            return FOUR_SPACE_INDENTATION + JAVA_DOC_PARAM + inputName + SPACE + RPC_INPUT_STRING + rpcName + NEW_LINE;
+        }
+    }
+
+    /**
+     * Generates javaDoc for the interface.
+     *
+     * @param interfaceName interface name
+     * @return javaDocs
+     */
+    private static String generateForRpcInterface(String interfaceName) {
+        return NEW_LINE + JAVA_DOC_FIRST_LINE + INTERFACE_JAVA_DOC + interfaceName + PERIOD + NEW_LINE
+                + JAVA_DOC_END_LINE;
+    }
+
+    /**
      * Generates javaDocs for getter method.
      *
      * @param attribute attribute
@@ -275,7 +359,7 @@
      * @param attribute attribute
      * @return javaDocs
      */
-    private static String generateForUnionFrom(String attribute) {
+    private static String generateForFromString(String attribute) {
 
         return NEW_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_FIRST_LINE + FOUR_SPACE_INDENTATION + JAVA_DOC_OF
                 + attribute + SPACE + FROM_STRING_METHOD_NAME + SPACE + INPUT + SPACE + STRING_DATA_TYPE + PERIOD
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
index 95c402a..61775f6 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/InputListenerTest.java
@@ -61,7 +61,7 @@
         assertThat(yangRpc.getName(), is("activate-software-image"));
 
         YangInput yangInput = (YangInput) yangRpc.getChild();
-        assertThat(yangInput.getName(), is("activate-software-imageInput"));
+        assertThat(yangInput.getName(), is("activate-software-image_input"));
         ListIterator<YangLeaf> leafIterator = yangInput.getListOfLeaf().listIterator();
         YangLeaf leafInfo = leafIterator.next();
 
@@ -102,7 +102,7 @@
         assertThat(yangRpc.getName(), is("activate-software-image"));
 
         YangInput yangInput = (YangInput) yangRpc.getChild();
-        assertThat(yangInput.getName(), is("activate-software-imageInput"));
+        assertThat(yangInput.getName(), is("activate-software-image_input"));
         YangTypeDef typeDef = (YangTypeDef) yangInput.getChild();
         assertThat(typeDef.getName(), is("my-type"));
         assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
index ded5c49..2ea9347 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OutputListenerTest.java
@@ -19,18 +19,17 @@
 import java.io.IOException;
 import java.util.ListIterator;
 import org.junit.Test;
-
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.datamodel.YangNodeType;
-import org.onosproject.yangutils.datamodel.YangRpc;
 import org.onosproject.yangutils.datamodel.YangOutput;
-import org.onosproject.yangutils.datamodel.YangLeaf;
-import org.onosproject.yangutils.datamodel.YangList;
-import org.onosproject.yangutils.datamodel.YangContainer;
-import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangRpc;
 import org.onosproject.yangutils.datamodel.YangStatusType;
-import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
 
@@ -61,7 +60,7 @@
         assertThat(yangRpc.getName(), is("activate-software-image"));
 
         YangOutput yangOutput = (YangOutput) yangRpc.getChild();
-        assertThat(yangOutput.getName(), is("activate-software-imageOutput"));
+        assertThat(yangOutput.getName(), is("activate-software-image_output"));
         ListIterator<YangLeaf> leafIterator = yangOutput.getListOfLeaf().listIterator();
         YangLeaf leafInfo = leafIterator.next();
 
@@ -102,7 +101,7 @@
         assertThat(yangRpc.getName(), is("activate-software-image"));
 
         YangOutput yangOutput = (YangOutput) yangRpc.getChild();
-        assertThat(yangOutput.getName(), is("activate-software-imageOutput"));
+        assertThat(yangOutput.getName(), is("activate-software-image_output"));
         YangTypeDef typeDef = (YangTypeDef) yangOutput.getChild();
         assertThat(typeDef.getName(), is("my-type"));
         assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java
new file mode 100644
index 0000000..b1c7f74
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/translator/tojava/utils/RpcTranslatorTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2016-present 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.IOException;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorUtil.generateJavaCode;
+import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.clean;
+
+/**
+ * Unit tests for rpc translator.
+ */
+public final class RpcTranslatorTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks rpc translation should not result in any exception.
+     */
+    @Test
+    public void processRpcTranslator() throws IOException, ParserException {
+
+        String userDir = System.getProperty("user.dir");
+        YangNode node = manager.getDataModel("src/test/resources/RpcTranslator.yang");
+
+        YangPluginConfig yangPluginConfig = new YangPluginConfig();
+        yangPluginConfig.setCodeGenDir(userDir + "/target/RpcTestGenFile/");
+
+        generateJavaCode(node, yangPluginConfig);
+
+        clean(userDir + "/target/RpcTestGenFile/");
+    }
+    // TODO enhance the test cases, after having a framework of translator test.
+}
diff --git a/utils/yangutils/src/test/resources/RpcTranslator.yang b/utils/yangutils/src/test/resources/RpcTranslator.yang
new file mode 100644
index 0000000..15048e0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/RpcTranslator.yang
@@ -0,0 +1,17 @@
+module Sfc {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    rpc SFP {
+        input {
+            leaf port {
+                type string;
+            }
+        }
+        output {
+            leaf path {
+                type string;
+            }
+        }
+    }
+}