[ONOS-4527,ONOS-4524,ONOS-4536,ONOS-4541,ONOS-4549,ONOS-4550,ONOS-4557
,ONOS-4558,ONOS-4545,ONOS-4543,ONOS-4546]
 Checkstyle error in generated code handled and defect fixed.

Change-Id: Ifef5a22f91d4ee21767f1e2c6d0dd5b5b0b8cfcc
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 39e5148..ca214c7 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
@@ -197,6 +197,11 @@
     public static final String PARSE_BYTE = "parseByte";
 
     /**
+     * Static attribute for parse boolean.
+     */
+    public static final String PARSE_BOOLEAN = "parseBoolean";
+
+    /**
      * Static attribute for parse short.
      */
     public static final String PARSE_SHORT = "parseShort";
@@ -242,6 +247,11 @@
     public static final String SPACE = " ";
 
     /**
+     * Static attribute for subject.
+     */
+    public static final String SUBJECT = "Subject";
+
+    /**
      * Static attribute for ListenerRegistry.
      */
     public static final String LISTENER_REG = "ListenerRegistry";
@@ -254,7 +264,7 @@
     /**
      * Static attribute for listener package.
      */
-    public static final String LISTENER_PKG = "org.onosproject.event";
+    public static final String ONOS_EVENT_PKG = "org.onosproject.event";
 
     /**
      * Static attribute for colon.
@@ -787,6 +797,11 @@
     public static final String ENUM = "enum";
 
     /**
+     * Static attribute for type syntax.
+     */
+    public static final String TYPE = "Type";
+
+    /**
      * Static attribute for static syntax.
      */
     public static final String STATIC = "static";
@@ -852,6 +867,11 @@
     public static final String EVENT_LISTENER_STRING = "Listener";
 
     /**
+     * For event subject file generation.
+     */
+    public static final String EVENT_SUBJECT_NAME_SUFFIX = "EventSubject";
+
+    /**
      * Static attribute for impl syntax.
      */
     public static final String IMPL = "Impl";
@@ -957,6 +977,130 @@
     public static final String YANG_UTILS_TODO = "//TODO: YANG utils generated code";
 
     /**
+     * Static attribute for activate annotation.
+     */
+    public static final String ACTIVATE_ANNOTATION = "@Activate\n";
+
+    /**
+     * Static attribute for activate.
+     */
+    public static final String ACTIVATE = "activate";
+
+    /**
+     * Static attribute for activate annotation import.
+     */
+    public static final String ACTIVATE_ANNOTATION_IMPORT = "import org.apache.felix.scr.annotations.Activate;\n";
+
+    /**
+     * Static attribute for deactivate annotation.
+     */
+    public static final String DEACTIVATE_ANNOTATION = "@Deactivate\n";
+
+    /**
+     * Static attribute for deactivate.
+     */
+    public static final String DEACTIVATE = "deactivate";
+
+    /**
+     * Static attribute for deactivate annotation import.
+     */
+    public static final String DEACTIVATE_ANNOTATION_IMPORT =
+            "import org.apache.felix.scr.annotations.Deactivate;\n";
+
+    /**
+     * Static attribute for component annotation.
+     */
+    public static final String COMPONENT_ANNOTATION = "@Component";
+
+    /**
+     * Static attribute for immediate.
+     */
+    public static final String IMMEDIATE = "immediate";
+
+    /**
+     * Static attribute for component annotation import.
+     */
+    public static final String COMPONENT_ANNOTATION_IMPORT =
+            "import org.apache.felix.scr.annotations.Component;\n";
+
+    /**
+     * Static attribute for service annotation.
+     */
+    public static final String SERVICE_ANNOTATION = "@Service\n";
+
+    /**
+     * Static attribute for service annotation import.
+     */
+    public static final String SERVICE_ANNOTATION_IMPORT =
+            "import org.apache.felix.scr.annotations.Service;\n";
+
+    /**
+     * Static attribute for logger factory import.
+     */
+    public static final String LOGGER_FACTORY_IMPORT =
+            "import static org.slf4j.LoggerFactory.getLogger;\n";
+
+    /**
+     * Static attribute for logger import.
+     */
+    public static final String LOGGER_IMPORT =
+            "import org.slf4j.Logger;\n";
+
+    /**
+     * Static attribute for logger statement.
+     */
+    public static final String LOGGER_STATEMENT =
+            "\n    private final Logger log = getLogger(getClass());\n";
+
+    /**
+     * Static attribute for logger statement for started.
+     */
+    public static final String STARTED_LOG_INFO =
+            "log.info(\"Started\");\n";
+
+    /**
+     * Static attribute for logger statement for stopped.
+     */
+    public static final String STOPPED_LOG_INFO =
+            "log.info(\"Stopped\");\n";
+
+    /**
+     * Static attribute for AbstractEvent.
+     */
+    public static final String ABSTRACT_EVENT = "AbstractEvent";
+
+    /**
+     * Static attribute for EventListener.
+     */
+    public static final String EVENT_LISTENER = "EventListener";
+
+    /**
+     * Static attribute for YangBinary class.
+     */
+    public static final String YANG_BINARY_CLASS = "YangBinary";
+
+    /**
+     * Static attribute for YangBinary class.
+     */
+    public static final String YANG_BITS_CLASS = "YangBits";
+
+    /**
+     * Static attribute for YANG types package.
+     */
+    public static final String YANG_TYPES_PKG = "org.onosproject.yangutils.utils.builtindatatype";
+
+    /**
+     * Static attribute for MathContext class.
+     */
+    public static final String MATH_CONTEXT = "MathContext";
+
+    /**
+     * Static attribute for DECIMAL64 class.
+     */
+    public static final String YANG_DECIMAL64_CLASS = "YangDecimal64";
+
+
+    /**
      * Static attribute for YANG file error.
      */
     public static final String YANG_FILE_ERROR = "YANG file error : ";
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBinary.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBinary.java
new file mode 100644
index 0000000..51747f3
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBinary.java
@@ -0,0 +1,104 @@
+/*
+ * 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.utils.builtindatatype;
+
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Represents binary data type.
+ */
+public final class YangBinary {
+
+    private byte[] byteArray;
+
+    /**
+     * Creates an instance of YANG binary.
+     */
+    private YangBinary() {
+    }
+
+    /**
+     * Creates an instance of YANG binary.
+     *
+     * @param bytes byte array
+     */
+    public YangBinary(byte[] bytes) {
+        this.byteArray = bytes;
+    }
+
+    /**
+     * Returns object of YANG binary.
+     *
+     * @param bytes byte array
+     * @return object of YANG binary
+     */
+    public static YangBinary of(byte[] bytes) {
+        return new YangBinary(bytes);
+    }
+
+    /**
+     * Returns byte array.
+     *
+     * @return byte array
+     */
+    public byte[] byteArray() {
+        return byteArray;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(byteArray);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof YangBinary) {
+            YangBinary other = (YangBinary) obj;
+            return Objects.equals(byteArray, other.byteArray);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("byteArray", byteArray)
+                .toString();
+    }
+
+    /**
+     * Returns the object of YANG binary fromString input String.
+     *
+     * @param valInString input String
+     * @return Object of YANG binary
+     */
+    public static YangBinary fromString(String valInString) {
+        try {
+            byte[] tmpVal = valInString.getBytes();
+            return of(tmpVal);
+        } catch (Exception e) {
+        }
+        return null;
+    }
+
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBits.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBits.java
new file mode 100644
index 0000000..60b0c32
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangBits.java
@@ -0,0 +1,104 @@
+/*
+ * 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.utils.builtindatatype;
+
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Represents bits data type.
+ */
+public class YangBits {
+
+    private byte[] byteArray;
+
+    /**
+     * Creates an instance of YANG bits.
+     */
+    private YangBits() {
+    }
+
+    /**
+     * Creates an instance of YANG bits.
+     *
+     * @param bytes byte array
+     */
+    public YangBits(byte[] bytes) {
+        this.byteArray = bytes;
+    }
+
+    /**
+     * Returns object of YANG bits.
+     *
+     * @param bytes byte array
+     * @return object of YANG bits
+     */
+    public static YangBits of(byte[] bytes) {
+        return new YangBits(bytes);
+    }
+
+    /**
+     * Returns byte array.
+     *
+     * @return byte array
+     */
+    public byte[] byteArray() {
+        return byteArray;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(byteArray);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof YangBits) {
+            YangBits other = (YangBits) obj;
+            return Objects.equals(byteArray, other.byteArray);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("byteArray", byteArray)
+                .toString();
+    }
+
+    /**
+     * Returns the object of YANG bits fromString input String.
+     *
+     * @param valInString input String
+     * @return Object of YANG bits
+     */
+    public static YangBits fromString(String valInString) {
+        try {
+            byte[] tmpVal = valInString.getBytes();
+            return of(tmpVal);
+        } catch (Exception e) {
+        }
+        return null;
+    }
+
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangDecimal64.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangDecimal64.java
new file mode 100644
index 0000000..8b3a0eb
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/builtindatatype/YangDecimal64.java
@@ -0,0 +1,112 @@
+/*
+ * 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.utils.builtindatatype;
+
+import java.util.Objects;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * Represents YANG decimal 64.
+ */
+public class YangDecimal64 {
+
+    private int fractionDigit;
+
+    /**
+     * Creates an instance of YANG decimal64.
+     */
+    public YangDecimal64() {
+    }
+
+    /**
+     * Creates an instance of of YANG decimal64.
+     *
+     * @param fractionDigit fraction digit
+     */
+    public YangDecimal64(int fractionDigit) {
+        this.setFractionDigit(fractionDigit);
+    }
+
+    /**
+     * Returns fraction digit.
+     *
+     * @return the fractionDigit
+     */
+    public int getFractionDigit() {
+        return fractionDigit;
+    }
+
+    /**
+     * Sets fraction digit.
+     *
+     * @param fractionDigit fraction digits.
+     */
+    public void setFractionDigit(int fractionDigit) {
+        this.fractionDigit = fractionDigit;
+    }
+
+    /**
+     * Returns object of YANG decimal64.
+     *
+     * @param value fraction digit
+     * @return YANG decimal64
+     */
+    public static YangDecimal64 of(int value) {
+        return new YangDecimal64(value);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(fractionDigit);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof YangDecimal64) {
+            YangDecimal64 other = (YangDecimal64) obj;
+            return Objects.equals(fractionDigit, other.fractionDigit);
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .omitNullValues()
+                .add("fractionDigit", fractionDigit)
+                .toString();
+    }
+
+    /**
+     * Returns the object of YANG decimal64 fromString input String.
+     *
+     * @param valInString input String
+     * @return Object of YANG decimal64
+     */
+    public static YangDecimal64 fromString(String valInString) {
+        try {
+            int tmpVal = Integer.parseInt(valInString);
+            return of(tmpVal);
+        } catch (Exception e) {
+        }
+        return null;
+    }
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
index 7d8fd84..cef7706 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/FileSystemUtil.java
@@ -22,6 +22,8 @@
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.List;
 
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.translator.exception.TranslatorException;
@@ -84,10 +86,12 @@
                 YangNode parent = getParentNodeInGenCode(yangNode);
                 if (parent != null) {
                     pkgInfo = ((JavaFileInfoContainer) parent).getJavaFileInfo().getJavaName();
-                    addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), true);
+                    addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), true,
+                            ((JavaFileInfoContainer) parent).getJavaFileInfo().getPluginConfig());
                 } else {
                     pkgInfo = ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getJavaName();
-                    addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), false);
+                    addPackageInfo(pack, pkgInfo, getJavaPackageFromPackagePath(pkg), false,
+                            ((JavaFileInfoContainer) yangNode).getJavaFileInfo().getPluginConfig());
                 }
             } catch (IOException e) {
                 throw new IOException("failed to create package-info file");
@@ -120,6 +124,7 @@
      */
     public static String readAppendFile(String toAppend, String spaces)
             throws IOException {
+
         FileReader fileReader = new FileReader(toAppend);
         BufferedReader bufferReader = new BufferedReader(fileReader);
         try {
@@ -156,15 +161,22 @@
      */
     public static void updateFileHandle(File inputFile, String contentTobeAdded, boolean isClose)
             throws IOException {
+
+        List<FileWriter> fileWriterStore = new ArrayList<>();
+
         FileWriter fileWriter = new FileWriter(inputFile, true);
+        fileWriterStore.add(fileWriter);
         PrintWriter outputPrintWriter = new PrintWriter(fileWriter, true);
         if (!isClose) {
             outputPrintWriter.write(contentTobeAdded);
             outputPrintWriter.flush();
             outputPrintWriter.close();
         } else {
-            fileWriter.flush();
-            fileWriter.close();
+            for (FileWriter curWriter : fileWriterStore) {
+                curWriter.flush();
+                curWriter.close();
+                curWriter = null;
+            }
         }
     }
 }
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 335de7f..218f56d 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
@@ -17,6 +17,7 @@
 package org.onosproject.yangutils.utils.io.impl;
 
 import org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax;
+import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 
 import static org.onosproject.yangutils.translator.tojava.utils.JavaIdentifierSyntax.getCamelCase;
 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
@@ -181,7 +182,12 @@
         /**
          * For manager setters.
          */
-        MANAGER_SETTER_METHOD
+        MANAGER_SETTER_METHOD,
+
+        /**
+         * For event subject.
+         */
+        EVENT_SUBJECT_CLASS
     }
 
     /**
@@ -190,14 +196,15 @@
      * @param type java doc type
      * @param name name of the YangNode
      * @param isList is list attribute
+     * @param pluginConfig plugin configurations
      * @return javadocs.
      */
-    public static String getJavaDoc(JavaDocType type, String name, boolean isList) {
+    public static String getJavaDoc(JavaDocType type, String name, boolean isList, YangPluginConfig pluginConfig) {
 
-        name = JavaIdentifierSyntax.getSmallCase(getCamelCase(name, null));
+        name = JavaIdentifierSyntax.getSmallCase(getCamelCase(name, pluginConfig.getConflictResolver()));
         switch (type) {
             case IMPL_CLASS: {
-                return generateForImplClass(name);
+                return generateForClass(name);
             }
             case BUILDER_CLASS: {
                 return generateForBuilderClass(name);
@@ -248,7 +255,7 @@
                return generateForRpcService(name);
             }
             case RPC_MANAGER: {
-               return generateForImplClass(name);
+               return generateForClass(name);
             }
             case EVENT: {
                 return generateForEvent(name);
@@ -256,6 +263,9 @@
             case EVENT_LISTENER: {
                 return generateForEventListener(name);
             }
+            case EVENT_SUBJECT_CLASS: {
+                return generateForClass(name);
+            }
             default: {
                 return generateForConstructors(name);
             }
@@ -279,14 +289,17 @@
      * @param rpcName name of the rpc
      * @param inputName name of input
      * @param outputName name of output
+     * @param pluginConfig plugin configurations
      * @return javaDocs of rpc method
      */
-    public static String generateJavaDocForRpc(String rpcName, String inputName, String outputName) {
-        rpcName = getCamelCase(rpcName, null);
+    public static String generateJavaDocForRpc(String rpcName, String inputName, String outputName,
+            YangPluginConfig pluginConfig) {
+        rpcName = getCamelCase(rpcName, pluginConfig.getConflictResolver());
 
-        String javadoc = 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);
+        String javadoc =
+                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);
         if (!outputName.equals(VOID)) {
             javadoc = javadoc + getOutputString(outputName, rpcName);
         }
@@ -470,7 +483,7 @@
      * @param className class name
      * @return javaDocs
      */
-    private static String generateForImplClass(String className) {
+    private static String generateForClass(String className) {
         return NEW_LINE + JAVA_DOC_FIRST_LINE + IMPL_CLASS_JAVA_DOC + className + PERIOD + NEW_LINE + JAVA_DOC_END_LINE;
     }
 
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java
index 4a3f847..ff2e3e7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangFileScanner.java
@@ -60,8 +60,8 @@
      *                              operations
      */
     public static List<String> getYangFiles(String root) throws IOException {
-        List<String> yangFiles = getFiles(root, YANG_FILE_EXTENTION);
-        return yangFiles;
+
+        return getFiles(root, YANG_FILE_EXTENTION);
     }
 
     /**
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
index 835b675..b505111 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/utils/io/impl/YangIoUtils.java
@@ -16,32 +16,38 @@
 
 package org.onosproject.yangutils.utils.io.impl;
 
+import java.io.BufferedReader;
 import java.io.BufferedWriter;
 import java.io.File;
+import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
 import java.util.Iterator;
-import java.util.List;
 import java.util.LinkedList;
-import java.util.Stack;
+import java.util.List;
 import java.util.Set;
+import java.util.Stack;
+import java.util.regex.Pattern;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.model.Resource;
 import org.apache.maven.project.MavenProject;
 import org.onosproject.yangutils.plugin.manager.YangFileInfo;
-
+import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
 import org.slf4j.Logger;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.HASH;
 import static org.onosproject.yangutils.utils.UtilConstants.NEW_LINE;
+import static org.onosproject.yangutils.utils.UtilConstants.OPEN_PARENTHESIS;
 import static org.onosproject.yangutils.utils.UtilConstants.ORG;
 import static org.onosproject.yangutils.utils.UtilConstants.PACKAGE;
+import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
 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;
@@ -61,6 +67,9 @@
 
     private static final Logger log = getLogger(YangIoUtils.class);
     private static final String TARGET_RESOURCE_PATH = SLASH + TEMP + SLASH + YANG_RESOURCES + SLASH;
+    private static final int LINE_SIZE = 116;
+    private static final int SUB_LINE_SIZE = 112;
+    private static final int ZERO = 0;
 
     /**
      * Creates an instance of YANG io utils.
@@ -83,19 +92,19 @@
     /**
      * Adds package info file for the created directory.
      *
-     * @param path        directory path
-     * @param classInfo   class info for the package
-     * @param pack        package of the directory
+     * @param path directory path
+     * @param classInfo class info for the package
+     * @param pack package of the directory
      * @param isChildNode is it a child node
+     * @param pluginConfig plugin configurations
      * @throws IOException when fails to create package info file
      */
-    public static void addPackageInfo(File path, String classInfo, String pack, boolean isChildNode)
+    public static void addPackageInfo(File path, String classInfo, String pack, boolean isChildNode,
+            YangPluginConfig pluginConfig)
             throws IOException {
 
-        if (pack.contains(ORG)) {
-            String[] strArray = pack.split(ORG);
-            pack = ORG + strArray[1];
-        }
+        pack = parsePkg(pack);
+
         try {
 
             File packageInfo = new File(path + SLASH + "package-info.java");
@@ -105,9 +114,12 @@
             BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
 
             bufferedWriter.write(CopyrightHeader.getCopyrightHeader());
-            bufferedWriter.write(getJavaDoc(PACKAGE_INFO, classInfo, isChildNode));
-            bufferedWriter.write(PACKAGE + SPACE + pack + SEMI_COLAN);
-
+            bufferedWriter.write(getJavaDoc(PACKAGE_INFO, classInfo, isChildNode, pluginConfig));
+            String pkg = PACKAGE + SPACE + pack + SEMI_COLAN;
+            if (pkg.length() > LINE_SIZE) {
+                pkg = whenDelimiterIsPersent(pkg, LINE_SIZE);
+            }
+            bufferedWriter.write(pkg);
             bufferedWriter.close();
             fileWriter.close();
         } catch (IOException e) {
@@ -116,6 +128,32 @@
     }
 
     /**
+     * Parses package and returns updated package.
+     *
+     * @param pack package needs to be updated
+     * @return updated package
+     */
+    public static String parsePkg(String pack) {
+
+        if (pack.contains(ORG)) {
+            String[] strArray = pack.split(ORG);
+            if (strArray.length >= 3) {
+                for (int i = 1; i < strArray.length; i++) {
+                    if (i == 1) {
+                        pack = ORG + strArray[1];
+                    } else {
+                        pack = pack + ORG + strArray[i];
+                    }
+                }
+            } else {
+                pack = ORG + strArray[1];
+            }
+        }
+
+        return pack;
+    }
+
+    /**
      * Cleans the generated directory if already exist in source folder.
      *
      * @param dir generated directory in previous build
@@ -169,7 +207,7 @@
     /**
      * Adds generated source directory to the compilation root.
      *
-     * @param source  directory
+     * @param source directory
      * @param project current maven project
      * @param context current build context
      */
@@ -182,7 +220,7 @@
     /**
      * Removes extra char from the string.
      *
-     * @param valueString    string to be trimmed
+     * @param valueString string to be trimmed
      * @param removealStirng extra chars
      * @return new string
      */
@@ -217,8 +255,8 @@
      * Returns the directory path of the package in canonical form.
      *
      * @param baseCodeGenPath base path where the generated files needs to be
-     *                        put
-     * @param pathOfJavaPkg   java package of the file being generated
+     *            put
+     * @param pathOfJavaPkg java package of the file being generated
      * @return absolute path of the package in canonical form
      */
     public static String getDirectory(String baseCodeGenPath, String pathOfJavaPkg) {
@@ -238,8 +276,8 @@
      * Returns the absolute path of the package in canonical form.
      *
      * @param baseCodeGenPath base path where the generated files needs to be
-     *                        put
-     * @param pathOfJavaPkg   java package of the file being generated
+     *            put
+     * @param pathOfJavaPkg java package of the file being generated
      * @return absolute path of the package in canonical form
      */
     public static String getAbsolutePackagePath(String baseCodeGenPath, String pathOfJavaPkg) {
@@ -249,9 +287,9 @@
     /**
      * Copies YANG files to the current project's output directory.
      *
-     * @param yangFileInfo set of YANG files
-     * @param outputDir    project's output directory
-     * @param project      maven project
+     * @param yangFileInfo list of YANG files
+     * @param outputDir project's output directory
+     * @param project maven project
      * @throws IOException when fails to copy files to destination resource directory
      */
     public static void copyYangFilesToTarget(Set<YangFileInfo> yangFileInfo, String outputDir, MavenProject project)
@@ -318,4 +356,113 @@
             throw new IOException("Failed to insert in " + file + "file");
         }
     }
+
+    /**
+     * Validates a line size in given file whether it is having more then 120 characters.
+     * If yes it will update and give a new file.
+     *
+     * @param dataFile file in which need to verify all lines.
+     * @return updated file
+     * @throws IOException when fails to do IO operations.
+     */
+    public static File validateLineLength(File dataFile) throws IOException {
+        File tempFile = dataFile;
+        FileReader fileReader = new FileReader(dataFile);
+        BufferedReader bufferReader = new BufferedReader(fileReader);
+        try {
+            StringBuilder stringBuilder = new StringBuilder();
+            String line = bufferReader.readLine();
+
+            while (line != null) {
+                if (line.length() > LINE_SIZE) {
+                    if (line.contains(PERIOD)) {
+                        line = whenDelimiterIsPersent(line, LINE_SIZE);
+                    } else if (line.contains(SPACE)) {
+                        line = whenSpaceIsPresent(line, LINE_SIZE);
+                    }
+                    stringBuilder.append(line);
+                } else {
+                    stringBuilder.append(line + NEW_LINE);
+                }
+                line = bufferReader.readLine();
+            }
+            FileWriter writer = new FileWriter(tempFile);
+            writer.write(stringBuilder.toString());
+            writer.close();
+            return tempFile;
+        } finally {
+            fileReader.close();
+            bufferReader.close();
+        }
+    }
+
+    /*When delimiters are present in the given line.*/
+    private static String whenDelimiterIsPersent(String line, int lineSize) {
+        StringBuilder stringBuilder = new StringBuilder();
+
+        if (line.length() > lineSize) {
+            String[] strArray = line.split(Pattern.quote(PERIOD));
+            stringBuilder = updateString(strArray, stringBuilder, PERIOD, lineSize);
+        } else {
+            stringBuilder.append(line + NEW_LINE);
+        }
+        String[] strArray = stringBuilder.toString().split(NEW_LINE);
+        StringBuilder tempBuilder = new StringBuilder();
+        for (String str : strArray) {
+            if (str.length() > SUB_LINE_SIZE) {
+                if (line.contains(PERIOD) && !line.contains(PERIOD + HASH + OPEN_PARENTHESIS)) {
+                    String[] strArr = str.split(Pattern.quote(PERIOD));
+                    tempBuilder = updateString(strArr, tempBuilder, PERIOD, SUB_LINE_SIZE);
+                } else if (str.contains(SPACE)) {
+                    tempBuilder.append(whenSpaceIsPresent(str, SUB_LINE_SIZE));
+                }
+            } else {
+                tempBuilder.append(str + NEW_LINE);
+            }
+        }
+        return tempBuilder.toString();
+
+    }
+
+    /*When spaces are present in the given line.*/
+    private static String whenSpaceIsPresent(String line, int lineSize) {
+        StringBuilder stringBuilder = new StringBuilder();
+        if (line.length() > lineSize) {
+            String[] strArray = line.split(SPACE);
+            stringBuilder = updateString(strArray, stringBuilder, SPACE, lineSize);
+        } else {
+            stringBuilder.append(line + NEW_LINE);
+        }
+        return stringBuilder.toString();
+    }
+
+    /*Updates the given line with the given size conditions.*/
+    private static StringBuilder updateString(String[] strArray, StringBuilder stringBuilder, String string,
+            int lineSize) {
+
+        StringBuilder tempBuilder = new StringBuilder();
+        for (String str : strArray) {
+            tempBuilder.append(str + string);
+            if (tempBuilder.length() > lineSize) {
+                String tempString = stringBuilder.toString();
+                stringBuilder.delete(ZERO, stringBuilder.length());
+                tempString = trimAtLast(tempString, string);
+                stringBuilder.append(tempString);
+                if (string.equals(PERIOD)) {
+                    stringBuilder.append(NEW_LINE + TWELVE_SPACE_INDENTATION + PERIOD + str + string);
+                } else {
+                    stringBuilder.append(NEW_LINE + TWELVE_SPACE_INDENTATION + str + string);
+                }
+                tempBuilder.delete(ZERO, tempBuilder.length());
+                tempBuilder.append(TWELVE_SPACE_INDENTATION);
+            } else {
+                stringBuilder.append(str + string);
+            }
+        }
+        String tempString = stringBuilder.toString();
+        tempString = trimAtLast(tempString, string);
+        stringBuilder.delete(ZERO, stringBuilder.length());
+        stringBuilder.append(tempString + NEW_LINE);
+        return stringBuilder;
+    }
 }