[ONOS-5876] YANG serializer helper utilits API

Change-Id: I0d04320fb16b1acd7bfef6dc76bb1f37bca2ce0c
diff --git a/runtime/pom.xml b/runtime/pom.xml
index 09d4b8b..b287993 100644
--- a/runtime/pom.xml
+++ b/runtime/pom.xml
@@ -29,6 +29,7 @@
 
     <modules>
         <module>api</module>
+        <module>utils</module>
     </modules>
 
     <dependencies>
diff --git a/runtime/utils/pom.xml b/runtime/utils/pom.xml
new file mode 100644
index 0000000..80ff720
--- /dev/null
+++ b/runtime/utils/pom.xml
@@ -0,0 +1,55 @@
+<!--
+  ~ Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+  ~ Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
+  ~ Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
+  ~ Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
+  ~ Vestibulum commodo. Ut rhoncus gravida arcu.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <dependencies>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-model</artifactId>
+            <version>1.12-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-yang-runtime-api</artifactId>
+            <version>1.12-SNAPSHOT</version>
+        </dependency>
+    </dependencies>
+
+    <parent>
+        <groupId>org.onosproject</groupId>
+        <artifactId>onos-yang-runtime</artifactId>
+        <version>1.12-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>onos-yang-runtime-utils</artifactId>
+    <packaging>jar</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>3.0.2</version>
+                <configuration>
+                    <skipIfEmpty>true</skipIfEmpty>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>default</id>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/SerializerHelper.java b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/SerializerHelper.java
new file mode 100644
index 0000000..a717942
--- /dev/null
+++ b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/SerializerHelper.java
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2017. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
+ * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan.
+ * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna.
+ * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus.
+ * Vestibulum commodo. Ut rhoncus gravida arcu.
+ */
+
+package org.onosproject.yang.runtime.utils;
+
+import org.onosproject.yang.model.DataNode;
+import org.onosproject.yang.model.ResourceId;
+import org.onosproject.yang.runtime.api.YangSerializerContext;
+
+import java.util.List;
+
+import static org.onosproject.yang.model.DataNode.Builder;
+
+/**
+ * Representation of serializer helper utilities, serializer can use them to
+ * build the data node and resource identifier without obtaining the schema
+ * context.
+ */
+public final class SerializerHelper {
+
+    /**
+     * Initializes resource identifier builder with YANG serializer context
+     * information.
+     *
+     * @param context YANG serializer context
+     * @return resource identifier builder
+     */
+    public static ResourceId.Builder initializeResourceId(
+            YangSerializerContext context) {
+        // TODO implementation
+        return null;
+    }
+
+    /**
+     * Adds to resource identifier builder. To add a top level logical
+     * resource identifier ("/"), name as "/" should be provided.
+     * <p>
+     * Builder and name are mandatory inputs, In case namespace is null,
+     * namespace of last key in the keylist of resource identifier builder will
+     * be used. Value should only be provided for leaf-list/list.
+     * <p>
+     * This API will also carry out necessary schema related validations.
+     *
+     * @param builder   resource identifier builder
+     * @param name      name of node
+     * @param namespace namespace of node
+     * @param value     value of node
+     * @return resource identifier builder
+     * @throws IllegalArgumentException when given input is not as per the
+     *                                  schema context
+     * @throws IllegalStateException    when a key is added under a atomic child
+     */
+    public static ResourceId.Builder addToResourceId(
+            ResourceId.Builder builder, String name, String namespace,
+            String value) {
+        // TODO implementation
+        return null;
+    }
+
+    /**
+     * Adds to resource identifier builder, this API will be used by
+     * applications which are not aware about the schema name association
+     * with key's value.
+     * <p>
+     * Builder and name are mandatory inputs, In case namespace is null,
+     * namespace of last key in the keylist of resource identifier builder will
+     * be used. Value should only be provided for leaf-list/list.
+     * <p>
+     * This API will also carry out necessary schema related validations.
+     *
+     * @param builder   resource identifier builder
+     * @param name      name of node
+     * @param namespace namespace of node
+     * @param value     ordered list of values
+     * @return resource identifier builder
+     * @throws IllegalArgumentException when given input is not as per the
+     *                                  schema context
+     * @throws IllegalStateException    when a key is added under a atomic child
+     */
+    public static ResourceId.Builder addToResourceId(
+            ResourceId.Builder builder, String name, String namespace,
+            List<String> value) {
+        // TODO implementation
+        return null;
+    }
+
+    /**
+     * Initializes a new data node builder.
+     *
+     * @param builder resource identifier builder
+     * @return data node builder
+     */
+    public static Builder initializeDataNode(ResourceId.Builder builder) {
+        // TODO implementation
+        return null;
+    }
+
+    /**
+     * Adds a data node to a given data node builder.
+     * <p>
+     * Name and builder is mandatory inputs. If namespace is not provided
+     * parents namespace will be added for data node. Value should be
+     * provided for leaf/leaf-list. In case of leaf-list it's expected that this
+     * API is called for each leaf-list instance. Callers aware about the node
+     * type can opt to provide data node type, implementation will carry out
+     * validations based on input type and obtained type.
+     * <p>
+     * This API will also carry out necessary schema related validations.
+     *
+     * @param builder   data node builder
+     * @param name      name of data node
+     * @param namespace namespace of data node
+     * @param value     value of data node
+     * @param type      type of data node
+     * @return data node builder with added information
+     * @throws IllegalArgumentException when given input is not as per the
+     *                                  schema context
+     * @throws IllegalStateException    when a key is added under a atomic child
+     */
+    public static Builder addDataNode(Builder builder,
+                                      String name, String namespace,
+                                      String value, DataNode type) {
+        // TODO implementation
+        return null;
+    }
+
+    /**
+     * Exits a given data node builder. It builds current data node,
+     * adds it to parent's data node builder and returns parent builder.
+     * <p>
+     * In case current data node is topmost node (which was created using
+     * last key of resource identifier), current data node will not be
+     * built and null will be returned, in such case caller is expected to
+     * build data node from builder.
+     * <p>
+     * This API will also carry out necessary exit time validations, for
+     * an example validation about all key leafs presence for a list.
+     *
+     * @param builder data node builder
+     * @return parent builder
+     */
+    public static Builder exitDataNode(Builder builder) {
+        // TODO implementation
+        return null;
+    }
+
+    /**
+     * Returns resource identifier for a given data node. This API will
+     * be used by serializer to obtain the resource identifier in the
+     * scenario when an annotation is associated with a given data node.
+     *
+     * @param builder data node builder
+     * @return resource identifier of the data node
+     */
+    public static ResourceId getResourceId(Builder builder) {
+        // TODO implementation
+        return null;
+    }
+}
diff --git a/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/package-info.java b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/package-info.java
new file mode 100644
index 0000000..145ee65
--- /dev/null
+++ b/runtime/utils/src/main/java/org/onosproject/yang/runtime/utils/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-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.
+ */
+
+/**
+ * Representation of YANG runtime utilities.
+ */
+package org.onosproject.yang.runtime.utils;
\ No newline at end of file