Merge "Generated code changes for RPC"
diff --git a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java
index 9c7f286..f714eff 100644
--- a/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java
+++ b/compiler/base/translator/src/main/java/org/onosproject/yang/compiler/translator/tojava/TempJavaRpcCommandFragmentFiles.java
@@ -29,7 +29,9 @@
 import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.findRpcInput;
 import static org.onosproject.yang.compiler.datamodel.utils.DataModelUtils.findRpcOutput;
 import static org.onosproject.yang.compiler.translator.tojava.utils.JavaFileGenerator.generateRpcCommand;
+import static org.onosproject.yang.compiler.translator.tojava.utils.JavaIdentifierSyntax.createPackage;
 import static org.onosproject.yang.compiler.translator.tojava.utils.MethodClassTypes.CLASS_TYPE;
+import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getImportString;
 import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getOverRideString;
 import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.getVariableDeclaration;
 import static org.onosproject.yang.compiler.translator.tojava.utils.StringGenerator.multiAttrMethodSignature;
@@ -43,14 +45,17 @@
 import static org.onosproject.yang.compiler.utils.UtilConstants.COMMAND;
 import static org.onosproject.yang.compiler.utils.UtilConstants.CREATE_DATA_NODE;
 import static org.onosproject.yang.compiler.utils.UtilConstants.CREATE_MODEL;
-import static org.onosproject.yang.compiler.utils.UtilConstants.DATA_NODE;
 import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT_CAPS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT_MODEL_OBJECT_DATA;
+import static org.onosproject.yang.compiler.utils.UtilConstants.DEFAULT_RESOURCE_DATA;
 import static org.onosproject.yang.compiler.utils.UtilConstants.DYNAMIC_CONFIG_SERVICE;
 import static org.onosproject.yang.compiler.utils.UtilConstants.EIGHT_SPACE_INDENTATION;
 import static org.onosproject.yang.compiler.utils.UtilConstants.EQUAL;
 import static org.onosproject.yang.compiler.utils.UtilConstants.FOUR_SPACE_INDENTATION;
 import static org.onosproject.yang.compiler.utils.UtilConstants.INT;
 import static org.onosproject.yang.compiler.utils.UtilConstants.MODEL_CONVERTER;
+import static org.onosproject.yang.compiler.utils.UtilConstants.MODEL_OBJECT_DATA;
+import static org.onosproject.yang.compiler.utils.UtilConstants.MODEL_PKG;
 import static org.onosproject.yang.compiler.utils.UtilConstants.NEW;
 import static org.onosproject.yang.compiler.utils.UtilConstants.NEW_LINE;
 import static org.onosproject.yang.compiler.utils.UtilConstants.NULL;
@@ -60,12 +65,14 @@
 import static org.onosproject.yang.compiler.utils.UtilConstants.PRIVATE;
 import static org.onosproject.yang.compiler.utils.UtilConstants.PUBLIC;
 import static org.onosproject.yang.compiler.utils.UtilConstants.QUOTES;
+import static org.onosproject.yang.compiler.utils.UtilConstants.RESOURCE_DATA;
 import static org.onosproject.yang.compiler.utils.UtilConstants.RESOURCE_ID;
 import static org.onosproject.yang.compiler.utils.UtilConstants.RETURN;
 import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_EXTENDED_COMMAND;
 import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_INPUT;
 import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_OUTPUT;
 import static org.onosproject.yang.compiler.utils.UtilConstants.RPC_SUCCESS;
+import static org.onosproject.yang.compiler.utils.UtilConstants.RUNTIME_PKG;
 import static org.onosproject.yang.compiler.utils.UtilConstants.SEMI_COLON;
 import static org.onosproject.yang.compiler.utils.UtilConstants.SERVICE;
 import static org.onosproject.yang.compiler.utils.UtilConstants.SIXTEEN_SPACE_INDENTATION;
@@ -105,10 +112,17 @@
     private static final String VAR_INPUT_OBJECT = "inputObject";
     private static final String VAR_OUTPUT_OBJECT = "outputObject";
     private static final String RPC_RESPONSE = "rpcResponse";
-    private static final String VAR_DATA_NODE = "dataNode";
+    private static final String VAR_INPUT_MO = "inputMo";
+    private static final String VAR_OUTPUT_MO = "outputMo";
+    private static final String VAR_INPUT_DATA = "inputData";
+    private static final String VAR_OUTPUT_DATA = "outputData";
+    private static final String BUILDER_METHOD = "builder";
+    private static final String ADD_DATA_NODE = "addDataNode";
+    private static final String ADD_MODEL_OBJECT = "addModelObject";
+    private static final String VAR_RESOURCE_ID = "resourceId";
 
     @Override
-    public void generateJavaFile(int fileType, YangNode curNode) {
+    public void generateJavaFile(int fileType, YangNode curNode) throws IOException {
         JavaImportData importData = ((JavaCodeGeneratorInfo) curNode)
                 .getTempJavaCodeFragmentFiles().getRpcCommandTempFiles()
                 .getJavaImportData();
@@ -117,6 +131,7 @@
                 curNode.getParent().getJavaClassNameOrBuiltInType(), null));
         String className = getCapitalCase(getCamelCase(
                 curNode.getJavaClassNameOrBuiltInType(), null) + COMMAND);
+        createPackage(curNode);
 
         // add RPC input import
         YangNode inputNode = findRpcInput(curNode);
@@ -140,8 +155,6 @@
             outputImport.setPkgInfo(outputNode.getJavaPackage());
             outputImport.setClassInfo(getCapitalCase(getCamelCase(
                     outputNode.getJavaClassNameOrBuiltInType(), null)));
-            importData.addImportInfo(outputImport, className,
-                                     curNode.getJavaPackage());
 
             JavaQualifiedTypeInfoTranslator defaultOutput = new
                     JavaQualifiedTypeInfoTranslator();
@@ -152,6 +165,7 @@
                                  null)));
             importData.addImportInfo(defaultOutput, className,
                                      curNode.getJavaPackage());
+
         }
 
         // add application service import
@@ -179,15 +193,23 @@
         imports.add(importData.getImportForRpcInput());
         imports.add(importData.getImportForRpcOutput());
         imports.add(importData.getImportForDynamicStoreService());
-        imports.add(importData.getImportForDataNode());
+        if (inputNode != null || outputNode != null) {
+            imports.add(getImportString(MODEL_PKG, RESOURCE_DATA));
+            imports.add(getImportString(MODEL_PKG, MODEL_OBJECT_DATA));
+        }
+        if (inputNode != null) {
+            imports.add(getImportString(RUNTIME_PKG, DEFAULT_RESOURCE_DATA));
+        }
+        if (outputNode != null) {
+            imports.add(getImportString(MODEL_PKG, DEFAULT_MODEL_OBJECT_DATA));
+        }
         imports.add(importData.getImportForRpcSuccess());
-
         try {
             rpcCommandClassTempFileHandle = getJavaFileHandle(className);
             generateRpcCommand(rpcCommandClassTempFileHandle, curNode, imports);
         } catch (IOException e) {
             throw new TranslatorException(
-                    "Failed to generate code for RPC command" + curNode.getName());
+                    "Failed to generate code for RPC command " + curNode.getName());
         }
     }
 
@@ -376,15 +398,14 @@
         StringBuilder builder = new StringBuilder();
         YangNode inputNode = findRpcInput(node);
         if (inputNode != null) {
-            String inputName = getCapitalCase(getCamelCase(
-                    inputNode.getJavaClassNameOrBuiltInType(), null));
-            builder.append(EIGHT_SPACE_INDENTATION).append(inputName).append(SPACE)
-                    .append(VAR_INPUT_OBJECT).append(SPACE).append(EQUAL).append(SPACE)
+            // build resource data
+            builder.append(buildResourceData())
+                    .append(EIGHT_SPACE_INDENTATION).append(MODEL_OBJECT_DATA).append(SPACE)
+                    .append(VAR_INPUT_MO).append(SPACE).append(EQUAL).append(SPACE)
                     .append(VAR_MODEL_CONVERTER).append(PERIOD)
                     .append(CREATE_MODEL).append(OPEN_PARENTHESIS)
-                    .append(VAR_RPC_INPUT).append(PERIOD).append(VAR_INPUT)
-                    .append(OPEN_PARENTHESIS).append(CLOSE_PARENTHESIS)
-                    .append(CLOSE_PARENTHESIS).append(SEMI_COLON).append(NEW_LINE);
+                    .append(VAR_INPUT_DATA).append(CLOSE_PARENTHESIS)
+                    .append(SEMI_COLON).append(NEW_LINE);
         }
         return builder.toString();
     }
@@ -398,15 +419,13 @@
         StringBuilder builder = new StringBuilder();
         YangNode outputNode = findRpcOutput(node);
         if (outputNode != null) {
-            String outputName = getCapitalCase(getCamelCase(
-                    outputNode.getJavaClassNameOrBuiltInType(), null));
-            builder.append(EIGHT_SPACE_INDENTATION).append(DATA_NODE).append(SPACE)
-                    .append(VAR_DATA_NODE).append(SPACE).append(EQUAL)
-                    .append(SPACE).append(VAR_MODEL_CONVERTER).append(PERIOD)
+            // create model object data
+            builder.append(buildModelObjectData());
+            builder.append(EIGHT_SPACE_INDENTATION).append(RESOURCE_DATA)
+                    .append(SPACE).append(VAR_OUTPUT_DATA).append(SPACE)
+                    .append(EQUAL).append(SPACE).append(VAR_MODEL_CONVERTER).append(PERIOD)
                     .append(CREATE_DATA_NODE).append(OPEN_PARENTHESIS)
-                    .append(OPEN_PARENTHESIS).append(DEFAULT_CAPS)
-                    .append(outputName).append(CLOSE_PARENTHESIS).append(SPACE)
-                    .append(VAR_OUTPUT_OBJECT).append(CLOSE_PARENTHESIS)
+                    .append(VAR_OUTPUT_MO).append(CLOSE_PARENTHESIS)
                     .append(SEMI_COLON).append(NEW_LINE);
         }
         return builder.toString();
@@ -431,23 +450,27 @@
         }
 
         if (inputNode != null && outputNode != null) {
-            builder.append(EIGHT_SPACE_INDENTATION).append(outputName)
-                    .append(SPACE).append(VAR_OUTPUT_OBJECT).append(SPACE)
-                    .append(EQUAL).append(SPACE).append(appService)
-                    .append(PERIOD).append(rpc).append(OPEN_PARENTHESIS)
-                    .append(VAR_INPUT_OBJECT).append(CLOSE_PARENTHESIS)
+            builder.append(getInputObject(inputNode));
+            builder.append(EIGHT_SPACE_INDENTATION).append(DEFAULT_CAPS)
+                    .append(outputName).append(SPACE).append(VAR_OUTPUT_OBJECT)
+                    .append(SPACE).append(EQUAL).append(SPACE).append(OPEN_PARENTHESIS)
+                    .append(DEFAULT_CAPS).append(outputName).append(CLOSE_PARENTHESIS)
+                    .append(SPACE).append(appService).append(PERIOD).append(rpc)
+                    .append(OPEN_PARENTHESIS).append(VAR_INPUT_OBJECT).append(CLOSE_PARENTHESIS)
                     .append(SEMI_COLON).append(NEW_LINE);
         } else if (inputNode != null && outputNode == null) {
+            builder.append(getInputObject(inputNode));
             builder.append(EIGHT_SPACE_INDENTATION).append(appService)
                     .append(PERIOD).append(rpc).append(OPEN_PARENTHESIS)
                     .append(VAR_INPUT_OBJECT).append(CLOSE_PARENTHESIS)
                     .append(SEMI_COLON).append(NEW_LINE);
         } else if (inputNode == null && outputNode != null) {
-            builder.append(EIGHT_SPACE_INDENTATION).append(outputName)
-                    .append(SPACE).append(VAR_OUTPUT_OBJECT).append(SPACE)
-                    .append(EQUAL).append(SPACE).append(appService)
-                    .append(PERIOD).append(rpc).append(OPEN_PARENTHESIS)
-                    .append(CLOSE_PARENTHESIS).append(SEMI_COLON)
+            builder.append(EIGHT_SPACE_INDENTATION).append(DEFAULT_CAPS)
+                    .append(outputName).append(SPACE).append(VAR_OUTPUT_OBJECT)
+                    .append(SPACE).append(EQUAL).append(SPACE).append(OPEN_PARENTHESIS)
+                    .append(DEFAULT_CAPS).append(outputName).append(CLOSE_PARENTHESIS)
+                    .append(SPACE).append(appService).append(PERIOD).append(rpc)
+                    .append(OPEN_PARENTHESIS).append(CLOSE_PARENTHESIS).append(SEMI_COLON)
                     .append(NEW_LINE);
         } else {
             builder.append(EIGHT_SPACE_INDENTATION).append(appService)
@@ -466,7 +489,7 @@
      */
     private static String createRpcOutputString(YangNode node) {
         YangNode outputNode = findRpcOutput(node);
-        String dataNode = VAR_DATA_NODE;
+        String dataNode = "outputData.dataNodes().get(0)";
         if (outputNode == null) {
             dataNode = NULL;
         }
@@ -495,4 +518,75 @@
         return builder.toString();
     }
 
+
+    /**
+     * Returns create resource data string.
+     *
+     * @return create resource data string
+     */
+    private static String buildResourceData() {
+        StringBuilder builder = new StringBuilder();
+        builder.append(EIGHT_SPACE_INDENTATION).append(RESOURCE_DATA)
+                .append(SPACE).append(VAR_INPUT_DATA).append(SPACE).append(EQUAL)
+                .append(SPACE).append(DEFAULT_RESOURCE_DATA).append(PERIOD)
+                .append(BUILDER_METHOD).append(OPEN_PARENTHESIS)
+                .append(CLOSE_PARENTHESIS).append(NEW_LINE)
+                .append(SIXTEEN_SPACE_INDENTATION).append(PERIOD)
+                .append(VAR_RESOURCE_ID).append(OPEN_PARENTHESIS)
+                .append(GET_RESOURCE_ID).append(OPEN_PARENTHESIS)
+                .append(CLOSE_PARENTHESIS).append(CLOSE_PARENTHESIS)
+                .append(NEW_LINE).append(SIXTEEN_SPACE_INDENTATION).append(PERIOD)
+                .append(ADD_DATA_NODE).append(OPEN_PARENTHESIS)
+                .append(VAR_RPC_INPUT).append(PERIOD).append(VAR_INPUT)
+                .append(OPEN_PARENTHESIS).append(CLOSE_PARENTHESIS)
+                .append(CLOSE_PARENTHESIS).append(PERIOD)
+                .append(BUILD).append(OPEN_PARENTHESIS).append(CLOSE_PARENTHESIS)
+                .append(SEMI_COLON).append(NEW_LINE);
+        return builder.toString();
+    }
+
+
+    /**
+     * Returns input object string.
+     *
+     * @param inputNode YANG RPC input node
+     * @return input object string
+     */
+    private static String getInputObject(YangNode inputNode) {
+        StringBuilder builder = new StringBuilder();
+        if (inputNode != null) {
+            String inputName = getCapitalCase(getCamelCase(
+                    inputNode.getJavaClassNameOrBuiltInType(), null));
+            String modelObject = "inputMo.modelObjects().get(0)";
+            return builder.append(EIGHT_SPACE_INDENTATION).append(inputName)
+                    .append(SPACE).append(VAR_INPUT_OBJECT)
+                    .append(SPACE).append(EQUAL).append(SPACE)
+                    .append(OPEN_PARENTHESIS).append(OPEN_PARENTHESIS)
+                    .append(inputName).append(CLOSE_PARENTHESIS).append(SPACE)
+                    .append(modelObject).append(CLOSE_PARENTHESIS)
+                    .append(SEMI_COLON).append(NEW_LINE).toString();
+        }
+        return null;
+    }
+
+    /**
+     * Returns model object data creation string.
+     *
+     * @return model object data string
+     */
+    private static String buildModelObjectData() {
+        StringBuilder builder = new StringBuilder();
+        return builder.append(EIGHT_SPACE_INDENTATION).append(MODEL_OBJECT_DATA)
+                .append(SPACE).append(VAR_OUTPUT_MO).append(SPACE).append(EQUAL)
+                .append(SPACE).append(DEFAULT_MODEL_OBJECT_DATA).append(PERIOD)
+                .append(BUILDER_METHOD).append(OPEN_PARENTHESIS)
+                .append(CLOSE_PARENTHESIS).append(NEW_LINE)
+                .append(SIXTEEN_SPACE_INDENTATION).append(PERIOD)
+                .append(ADD_MODEL_OBJECT).append(OPEN_PARENTHESIS)
+                .append(VAR_OUTPUT_OBJECT).append(CLOSE_PARENTHESIS)
+                .append(PERIOD).append(BUILD).append(OPEN_PARENTHESIS)
+                .append(CLOSE_PARENTHESIS).append(SEMI_COLON)
+                .append(NEW_LINE).toString();
+    }
+
 }
diff --git a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
index 215cac8..f2095e7 100644
--- a/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
+++ b/compiler/base/utils/src/main/java/org/onosproject/yang/compiler/utils/UtilConstants.java
@@ -1825,6 +1825,11 @@
     public static final String MODEL_PKG = "org.onosproject.yang.model";
 
     /**
+     * Static attribute for runtime import package.
+     */
+    public static final String RUNTIME_PKG = "org.onosproject.yang.runtime";
+
+    /**
      * Static attribute for RPC execution status import package.
      */
     public static final String RPC_OUTPUT_STATUS_PKG = "org.onosproject.config" +
@@ -1951,22 +1956,19 @@
             "capable of invoking the appropriate RPC command's execute method";
 
     public static final String RUNNABLE = "Runnable";
-
     public static final String RUN = "run";
-
     public static final String BUILDER = "Builder";
-
     public static final String BUILD = "build";
-
     public static final String ADD_BRANCH_POINT_SCHEMA = "addBranchPointSchema";
-
     public static final String CREATE_MODEL = "createModel";
-
     public static final String CREATE_DATA_NODE = "createDataNode";
-
     public static final String MULTI_INSTANCE_OBJECT = "MultiInstanceObject";
-
     public static final String KEY_INFO = "KeyInfo";
+    public static final String RESOURCE_DATA = "ResourceData";
+    public static final String DEFAULT_RESOURCE_DATA = "DefaultResourceData";
+    public static final String MODEL_OBJECT_DATA = "ModelObjectData";
+    public static final String DEFAULT_MODEL_OBJECT_DATA =
+            "DefaultModelObjectData";
 
     // No instantiation.
     private UtilConstants() {
diff --git a/model/src/main/java/org/onosproject/yang/model/DefaultModelObjectData.java b/model/src/main/java/org/onosproject/yang/model/DefaultModelObjectData.java
index a56f9c6..a1b5774 100644
--- a/model/src/main/java/org/onosproject/yang/model/DefaultModelObjectData.java
+++ b/model/src/main/java/org/onosproject/yang/model/DefaultModelObjectData.java
@@ -79,7 +79,7 @@
         }
 
         @Override
-        public Builder identifer(ModelObjectId id) {
+        public Builder identifier(ModelObjectId id) {
             identifier = id;
             return this;
         }
diff --git a/model/src/main/java/org/onosproject/yang/model/ModelObjectData.java b/model/src/main/java/org/onosproject/yang/model/ModelObjectData.java
index d4b0e1a..ec76697 100644
--- a/model/src/main/java/org/onosproject/yang/model/ModelObjectData.java
+++ b/model/src/main/java/org/onosproject/yang/model/ModelObjectData.java
@@ -62,7 +62,7 @@
          * @param id identifier
          * @return builder
          */
-        Builder identifer(ModelObjectId id);
+        Builder identifier(ModelObjectId id);
 
         /**
          * Builds an instance of model object data.
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYobBuilder.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYobBuilder.java
index fa0e804..1388548 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYobBuilder.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/DefaultYobBuilder.java
@@ -18,6 +18,7 @@
 
 import org.onosproject.yang.compiler.datamodel.YangLeaf;
 import org.onosproject.yang.compiler.datamodel.YangLeafList;
+import org.onosproject.yang.compiler.datamodel.YangRpc;
 import org.onosproject.yang.compiler.datamodel.YangSchemaNode;
 import org.onosproject.yang.model.DataNode;
 import org.onosproject.yang.model.DefaultModelObjectData;
@@ -84,7 +85,7 @@
                 }
             }
         }
-        return builder.identifer(id).build();
+        return builder.identifier(id).build();
     }
 
     /**
@@ -118,6 +119,13 @@
                                                       sId.namespace()));
                     }
 
+                    if (schemaNode instanceof YangRpc) {
+                        // RPC resource id need not be converted to model
+                        // object id.
+                        lastIndexNode = schemaNode;
+                        return null;
+                    }
+
                     if (key instanceof ListKey) {
                         midb = handleListKey(midb, registry, schemaNode, key);
                     } else if (key instanceof LeafListKey) {
diff --git a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
index 1e43f47..49fa058 100644
--- a/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
+++ b/runtime/src/main/java/org/onosproject/yang/runtime/impl/YobUtils.java
@@ -560,8 +560,7 @@
      */
     static LeafIdentifier getLeafIdentifier(SchemaId id,
                                             YangSchemaNode leafHolder,
-                                            DefaultYangModelRegistry
-                                                    reg) {
+                                            DefaultYangModelRegistry reg) {
         String qualName = getQualifiedDefaultClass(leafHolder);
         ClassLoader classLoader = getClassLoader(leafHolder, reg);
         try {
@@ -760,6 +759,7 @@
      * @param midb       model object identifier
      * @param reg        model registry
      * @param schemaNode leaf schema node
+     * @param key        leaf list node key
      * @return model object id builder
      */
     static ModelObjectId.Builder handleLeafListKey(
@@ -835,6 +835,7 @@
      *
      * @param midb       model object identifier builder
      * @param reg        model registry
+     * @param key        leaf node key
      * @param schemaNode YANG schema node
      * @return model object builder with single instance node
      */
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java
index 0e6a5ba..a998ab0 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DataTreeContextSwitchTest.java
@@ -185,7 +185,7 @@
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(lateNight);
         mid = ModelObjectId.builder().addChild(DefaultYtbFood.class).build();
-        data.identifer(mid);
+        data.identifier(mid);
         rscData = treeBuilder.getResourceData(data.build());
 
         nameSpace = "yms:test:ytb:simple:choice:case";
@@ -455,7 +455,7 @@
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(augCont2);
         mid = ModelObjectId.builder().addChild(DefaultCont1.class).build();
-        data.identifer(mid);
+        data.identifier(mid);
         rscData = treeBuilder.getResourceData(data.build());
 
         nameSpace = "yms:test:ytb:simple:augment";
@@ -537,7 +537,7 @@
         mid = ModelObjectId.builder().addChild(DefaultCont1.class)
                 .addChild(DefaultCont2.class).build();
 
-        data.identifer(mid);
+        data.identifier(mid);
         rscData = treeBuilder.getResourceData(data.build());
 
         nameSpace = "yms:test:ytb:simple:augment";
@@ -597,7 +597,7 @@
                 .addChild(DefaultCont2.class)
                 .addChild(DefaultCont1s.class).build();
 
-        data.identifer(mid);
+        data.identifier(mid);
         rscData = treeBuilder.getResourceData(data.build());
 
         nameSpace = "yms:test:ytb:simple:augment";
@@ -706,7 +706,7 @@
 
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(con);
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class).build());
 
         // Builds YANG tree in YTB.
@@ -749,7 +749,7 @@
         setUp();
 
         data = new DefaultModelObjectData.Builder();
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class)
                                .addChild(DefaultOnlyContainer.class).build());
 
@@ -799,7 +799,7 @@
 
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(con);
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class).build());
 
         // Builds YANG tree in YTB.
@@ -863,7 +863,7 @@
 
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(con);
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class).build());
 
         // Builds YANG tree in YTB.
@@ -943,7 +943,7 @@
 
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(con);
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class).build());
 
         // Builds YANG tree in YTB.
@@ -1051,7 +1051,7 @@
         DefaultContainerList con = new DefaultContainerList();
         con.listLeaf(list);
 
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class)
                                .addChild(DefaultContainerList.class).build());
 
@@ -1129,7 +1129,7 @@
         data = new DefaultModelObjectData.Builder();
         ListLeafKeys key = new ListLeafKeys();
         key.name("key leaf");
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class)
                                .addChild(DefaultContainerList.class)
                                .addChild(DefaultListLeaf.class, key).build());
@@ -1207,7 +1207,7 @@
 
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(con);
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class).build());
 
         // Builds YANG tree in YTB.
@@ -1274,7 +1274,7 @@
 
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(con);
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class).build());
 
         // Builds YANG tree in YTB.
@@ -1332,7 +1332,7 @@
 
         data = new DefaultModelObjectData.Builder();
         data.addModelObject(con);
-        data.identifer(ModelObjectId.builder()
+        data.identifier(ModelObjectId.builder()
                                .addChild(DefaultFirstLevel.class).build());
 
         // Builds YANG tree in YTB.
diff --git a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java
index 24a217e..945af8d 100644
--- a/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java
+++ b/runtime/src/test/java/org/onosproject/yang/runtime/impl/DefaultDataTreeBuilderTest.java
@@ -373,7 +373,7 @@
         mid = ModelObjectId.builder()
                 .addChild(DefaultModKey.class, keyKeys).build();
 
-        data.identifer(mid);
+        data.identifier(mid);
         rscData = treeBuilder.getResourceData(data.build());
 
         id = rscData.resourceId();
@@ -440,7 +440,7 @@
                 .addChild(DefaultModKey.class, keyKeys)
                 .addChild(ModKey.LeafIdentifier.TYPES).build();
 
-        data.identifer(mid);
+        data.identifier(mid);
         rscData = treeBuilder.getResourceData(data.build());
 
         id = rscData.resourceId();
@@ -621,7 +621,7 @@
 
         // Builds YANG tree in YTB.
         mid = ModelObjectId.builder().addChild(DefaultSched.class).build();
-        data.identifer(mid);
+        data.identifier(mid);
 
         rscData = treeBuilder.getResourceData(data.build());
 
@@ -864,7 +864,7 @@
         data = new DefaultModelObjectData.Builder();
         mid = ModelObjectId.builder()
                 .addChild(DefaultTestNotification.class).build();
-        data.identifer(mid);
+        data.identifier(mid);
 
         registry = ut.reg;
         DefaultDataTreeBuilder builder = new DefaultDataTreeBuilder(registry);
@@ -901,7 +901,7 @@
         data = new DefaultModelObjectData.Builder();
         mid = ModelObjectId.builder()
                 .addChild(DefaultTestNotification.class).build();
-        data.identifer(mid);
+        data.identifier(mid);
         data.addModelObject(new DefaultTestContainer());
 
         registry = ut.reg;
@@ -945,7 +945,7 @@
         data = new DefaultModelObjectData.Builder();
         mid = ModelObjectId.builder()
                 .addChild(DefaultTestInput.class).build();
-        data.identifer(mid);
+        data.identifier(mid);
 
         registry = ut.reg;
         DefaultDataTreeBuilder builder = new DefaultDataTreeBuilder(registry);
@@ -986,7 +986,7 @@
         data = new DefaultModelObjectData.Builder();
         mid = ModelObjectId.builder()
                 .addChild(DefaultTestInput.class).build();
-        data.identifer(mid);
+        data.identifier(mid);
         data.addModelObject(new org.onosproject.yang.runtime.mockclass
                 .testmodule.testrpc.testinput.DefaultTestContainer());
 
diff --git a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DataNodeJsonVisitor.java b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DataNodeJsonVisitor.java
index cc0e2ee..a943c66 100644
--- a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DataNodeJsonVisitor.java
+++ b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DataNodeJsonVisitor.java
@@ -35,6 +35,8 @@
 
     /**
      * Creates an instance of data node JSON visitor.
+     *
+     * @param jb json builder
      */
     public DataNodeJsonVisitor(JsonBuilder jb) {
         jsonBuilder = jb;
diff --git a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java
index eaa4bdf..2ad2a74 100644
--- a/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java
+++ b/serializers/json/src/main/java/org/onosproject/yang/serializers/json/DefaultJsonWalker.java
@@ -42,6 +42,8 @@
 
     /**
      * Creates an instance of JSON object node walker.
+     *
+     * @param db data node builder
      */
     public DefaultJsonWalker(DataNode.Builder db) {
         dataNodeBuilder = db;