[ONOS-4838] Decimal64 Range Restrictions Modification

Change-Id: I4d79c0da5ef400a188bfc5a85830e1187602e698
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
index 7a7439f..dee1c98 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
@@ -478,9 +478,7 @@
                 return RESOLVED;
             }
         } else if (getEffectiveBuiltInType() == DECIMAL64) {
-            if ((refDerivedInfo.getResolvedExtendedInfo() == null) ||
-                    (((YangDecimal64) refDerivedInfo.getResolvedExtendedInfo())
-                            .getRangeRestrictedExtendedInfo() == null)) {
+            if (refDerivedInfo.getResolvedExtendedInfo() == null) {
                 resolveRangeRestriction(null);
                  /*
                   * Return the resolution status as resolved, if it's not;
@@ -489,13 +487,12 @@
                   */
                 return RESOLVED;
             } else {
-                if (!(((YangDecimal64) refDerivedInfo.getResolvedExtendedInfo())
-                        .getRangeRestrictedExtendedInfo() instanceof YangRangeRestriction)) {
+                if (!(refDerivedInfo.getResolvedExtendedInfo() instanceof YangRangeRestriction)) {
                     throw new DataModelException("Linker error: Referred typedef restriction info is of invalid " +
                                                          "type.");
                 }
-                resolveRangeRestriction((YangRangeRestriction) ((YangDecimal64) refDerivedInfo
-                        .getResolvedExtendedInfo()).getRangeRestrictedExtendedInfo());
+                resolveRangeRestriction((YangRangeRestriction) refDerivedInfo
+                        .getResolvedExtendedInfo());
                 /*
                  * Return the resolution status as resolved, if it's not
                  * resolve range/string restriction will throw exception in
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
index 67ee69e..d4bb888 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaFragmentFiles.java
@@ -1613,7 +1613,6 @@
                     addBitsetImport(imports, false);
                 }
                 insertDataIntoJavaFile(getOpParamClassJavaFileHandle(), getJavaClassDefClose());
-
             }
         }
         /*
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
index c9d28a7..5aecdc4 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaFileGenerator.java
@@ -22,15 +22,19 @@
 import java.util.List;
 
 import org.onosproject.yangutils.datamodel.YangAugment;
+import org.onosproject.yangutils.datamodel.YangAugmentableNode;
 import org.onosproject.yangutils.datamodel.YangLeaf;
 import org.onosproject.yangutils.datamodel.YangLeafList;
 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
-import org.onosproject.yangutils.datamodel.YangAugmentableNode;
 import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
 import org.onosproject.yangutils.translator.tojava.JavaAttributeInfo;
 import org.onosproject.yangutils.translator.tojava.JavaCodeGeneratorInfo;
 import org.onosproject.yangutils.translator.tojava.JavaFileInfo;
 import org.onosproject.yangutils.translator.tojava.JavaFileInfoContainer;
+import org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo;
 import org.onosproject.yangutils.translator.tojava.TempJavaCodeFragmentFilesContainer;
 import org.onosproject.yangutils.translator.tojava.TempJavaEnumerationFragmentFiles;
 import org.onosproject.yangutils.translator.tojava.TempJavaServiceFragmentFiles;
@@ -70,6 +74,8 @@
 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.JavaAttributeInfo.getAttributeInfoForTheData;
+import static org.onosproject.yangutils.translator.tojava.JavaQualifiedTypeInfo.getQualifiedTypeInfoOfCurNode;
 import static org.onosproject.yangutils.translator.tojava.TempJavaFragmentFiles.getCurNodeAsAttributeInTarget;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.addAugmentationAttribute;
 import static org.onosproject.yangutils.translator.tojava.utils.JavaCodeSnippetGen.getEnumsValueAttribute;
@@ -111,6 +117,9 @@
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafListgetter;
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getToStringSelectLeafgetter;
 import static org.onosproject.yangutils.translator.tojava.utils.MethodsGenerator.getisFilterContentMatch;
+import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
+import static org.onosproject.yangutils.utils.UtilConstants.BINARY_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.BITS_STRING;
 import static org.onosproject.yangutils.utils.UtilConstants.BUILDER;
 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
@@ -122,6 +131,11 @@
 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_STRING;
 import static org.onosproject.yangutils.utils.UtilConstants.EVENT_SUBJECT_NAME_SUFFIX;
 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_ENCODER;
+import static org.onosproject.yangutils.utils.UtilConstants.ENCODE_TO_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_OBJECTS_IMPORT_PKG;
+import static org.onosproject.yangutils.utils.UtilConstants.JAVA_UTIL_IMPORT_BASE64_CLASS;
+import static org.onosproject.yangutils.utils.UtilConstants.IMPORT;
 import static org.onosproject.yangutils.utils.UtilConstants.INT;
 import static org.onosproject.yangutils.utils.UtilConstants.LOGGER_STATEMENT;
 import static org.onosproject.yangutils.utils.UtilConstants.MANAGER;
@@ -150,10 +164,13 @@
 import static org.onosproject.yangutils.utils.UtilConstants.OPEN_CURLY_BRACKET;
 import static org.onosproject.yangutils.utils.UtilConstants.MERGE;
 import static org.onosproject.yangutils.utils.UtilConstants.REPLACE;
+import static org.onosproject.yangutils.utils.UtilConstants.RETURN;
 import static org.onosproject.yangutils.utils.UtilConstants.CREATE;
 import static org.onosproject.yangutils.utils.UtilConstants.REMOVE;
 import static org.onosproject.yangutils.utils.UtilConstants.DELETE;
 import static org.onosproject.yangutils.utils.UtilConstants.PERIOD;
+import static org.onosproject.yangutils.utils.UtilConstants.STRING_DATA_TYPE;
+import static org.onosproject.yangutils.utils.UtilConstants.TO;
 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;
@@ -830,8 +847,15 @@
         JavaFileInfo javaFileInfo = ((JavaFileInfoContainer) curNode).getJavaFileInfo();
         YangPluginConfig pluginConfig = javaFileInfo.getPluginConfig();
 
+        // import
         String className = getCapitalCase(javaFileInfo.getJavaName());
         String path = javaFileInfo.getBaseCodeGenPath() + javaFileInfo.getPackageFilePath();
+        YangTypeDef typeDef = (YangTypeDef) curNode;
+        List<YangType<?>> types = typeDef.getTypeList();
+        YangType type = types.get(0);
+        if (type.getDataType().equals(YangDataTypes.BINARY)) {
+            imports.add(IMPORT + JAVA_UTIL_OBJECTS_IMPORT_PKG + PERIOD + JAVA_UTIL_IMPORT_BASE64_CLASS);
+        }
 
         initiateJavaFileGeneration(file, className, GENERATE_TYPEDEF_CLASS, imports, path, pluginConfig);
 
@@ -899,9 +923,39 @@
             /**
              * To string method.
              */
-            methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK,
+             if (type.getDataType().equals(YangDataTypes.BINARY)) {
+                    JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
+                                                                     getCapitalCase(BINARY_STRING));
+
+                    JavaAttributeInfo attr =  getAttributeInfoForTheData(qualifiedTypeInfo, BINARY_STRING, null, false,
+                                                                         false);
+                    String attributeName = attr.getAttributeName();
+                    String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC
+                            + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS
+                            + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
+                            + RETURN + SPACE + BASE64 + PERIOD + GET_ENCODER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS
+                            + PERIOD + ENCODE_TO_STRING + OPEN_PARENTHESIS + attributeName + CLOSE_PARENTHESIS
+                            + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET + NEW_LINE;
+                    methods.add(bitsToStringMethod);
+             } else if (type.getDataType().equals(YangDataTypes.BITS)) {
+                    JavaQualifiedTypeInfo qualifiedTypeInfo = getQualifiedTypeInfoOfCurNode(curNode,
+                                                                     getCapitalCase(BITS_STRING));
+
+                    JavaAttributeInfo attr =  getAttributeInfoForTheData(qualifiedTypeInfo, BITS_STRING,
+                                                                         null, false, false);
+                    String attributeName = attr.getAttributeName();
+                    String bitsToStringMethod = MethodsGenerator.getOverRideString() + FOUR_SPACE_INDENTATION + PUBLIC
+                            + SPACE + STRING_DATA_TYPE + SPACE + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS
+                            + CLOSE_PARENTHESIS + SPACE + OPEN_CURLY_BRACKET + NEW_LINE + EIGHT_SPACE_INDENTATION
+                            + RETURN + SPACE + attributeName + PERIOD + TO + STRING_DATA_TYPE + OPEN_PARENTHESIS
+                            + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET
+                            + NEW_LINE;
+                    methods.add(bitsToStringMethod);
+            } else {
+                methods.add(getToStringMethodOpen() + getDataFromTempFileHandle(TO_STRING_IMPL_MASK,
                     ((TempJavaCodeFragmentFilesContainer) curNode).getTempJavaCodeFragmentFiles().getTypeTempFiles(),
                     path) + getToStringMethodClose());
+            }
 
             JavaCodeGeneratorInfo javaGeninfo = (JavaCodeGeneratorInfo) curNode;
             /**
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
index 14243ca..ea7824f 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/MethodsGenerator.java
@@ -59,6 +59,7 @@
 import static org.onosproject.yangutils.utils.UtilConstants.AND;
 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTATION;
 import static org.onosproject.yangutils.utils.UtilConstants.AUGMENTED;
+import static org.onosproject.yangutils.utils.UtilConstants.BASE64;
 import static org.onosproject.yangutils.utils.UtilConstants.BIG_DECIMAL;
 import static org.onosproject.yangutils.utils.UtilConstants.BIG_INTEGER;
 import static org.onosproject.yangutils.utils.UtilConstants.BOOLEAN_DATA_TYPE;
@@ -74,10 +75,11 @@
 import static org.onosproject.yangutils.utils.UtilConstants.CLASS_STRING;
 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_CURLY_BRACKET;
 import static org.onosproject.yangutils.utils.UtilConstants.CLOSE_PARENTHESIS;
-import static org.onosproject.yangutils.utils.UtilConstants.COLAN;
+import static org.onosproject.yangutils.utils.UtilConstants.COLON;
 import static org.onosproject.yangutils.utils.UtilConstants.COMMA;
 import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE;
 import static org.onosproject.yangutils.utils.UtilConstants.DEACTIVATE_ANNOTATION;
+import static org.onosproject.yangutils.utils.UtilConstants.DECODE;
 import static org.onosproject.yangutils.utils.UtilConstants.DEFAULT;
 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_CLOSE_BRACKET;
 import static org.onosproject.yangutils.utils.UtilConstants.DIAMOND_OPEN_BRACKET;
@@ -89,11 +91,12 @@
 import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION;
 import static org.onosproject.yangutils.utils.UtilConstants.EXCEPTION_VAR;
 import static org.onosproject.yangutils.utils.UtilConstants.FALSE;
+import static org.onosproject.yangutils.utils.UtilConstants.FOR;
 import static org.onosproject.yangutils.utils.UtilConstants.FOUR_SPACE_INDENTATION;
 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_METHOD_NAME;
 import static org.onosproject.yangutils.utils.UtilConstants.FROM_STRING_PARAM_NAME;
 import static org.onosproject.yangutils.utils.UtilConstants.GET;
-import static org.onosproject.yangutils.utils.UtilConstants.GET_BYTES;
+import static org.onosproject.yangutils.utils.UtilConstants.GET_DECODER;
 import static org.onosproject.yangutils.utils.UtilConstants.GET_METHOD_PREFIX;
 import static org.onosproject.yangutils.utils.UtilConstants.GOOGLE_MORE_OBJECT_METHOD_STRING;
 import static org.onosproject.yangutils.utils.UtilConstants.HASH;
@@ -170,6 +173,12 @@
 import static org.onosproject.yangutils.utils.UtilConstants.APP_INSTANCE;
 import static org.onosproject.yangutils.utils.UtilConstants.NOT;
 import static org.onosproject.yangutils.utils.UtilConstants.OR_OPERATION;
+import static org.onosproject.yangutils.utils.UtilConstants.REPLACE_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.SINGLE_QUOTE;
+import static org.onosproject.yangutils.utils.UtilConstants.SPLIT_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.SQUARE_BRACKETS;
+import static org.onosproject.yangutils.utils.UtilConstants.TRIM_STRING;
+import static org.onosproject.yangutils.utils.UtilConstants.ZERO;
 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;
@@ -188,11 +197,15 @@
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.getSmallCase;
 import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.trimAtLast;
 import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BINARY;
+import static org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes.BITS;
 
 /**
  * Represents generator for methods of generated files based on the file type.
  */
 public final class MethodsGenerator {
+    private static final String BITS_STRING_ARRAY_VAR = "bitsTemp";
+    private static final String BIT_TEMP_VAR = "bitTemp";
+    private static final String FOR_TYPE = " for type ";
 
     /**
      * Creates an instance of method generator.
@@ -1085,14 +1098,39 @@
                                              JavaAttributeInfo fromStringAttributeInfo) {
 
         String targetDataType = getReturnType(attr);
-        if (fromStringAttributeInfo.getAttributeType().getDataType() == BINARY) {
-            return targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + FROM_STRING_PARAM_NAME
-                    + PERIOD + GET_BYTES + OPEN_PARENTHESIS + CLOSE_PARENTHESIS;
+        if (fromStringAttributeInfo.getAttributeType().getDataType() == BITS) {
+            String lines = targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + NEW + SPACE + targetDataType
+                    + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+            lines += TWELVE_SPACE_INDENTATION + FROM_STRING_PARAM_NAME + SPACE + EQUAL + SPACE + FROM_STRING_PARAM_NAME
+                    + PERIOD + REPLACE_STRING + OPEN_PARENTHESIS + SINGLE_QUOTE + OPEN_CURLY_BRACKET + SINGLE_QUOTE
+                    + COMMA + SPACE + SINGLE_QUOTE + SPACE + SINGLE_QUOTE + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+            lines += TWELVE_SPACE_INDENTATION + FROM_STRING_PARAM_NAME + SPACE + EQUAL + SPACE + FROM_STRING_PARAM_NAME
+                    + PERIOD + REPLACE_STRING + OPEN_PARENTHESIS + SINGLE_QUOTE + CLOSE_CURLY_BRACKET + SINGLE_QUOTE
+                    + COMMA + SPACE + SINGLE_QUOTE + SPACE + SINGLE_QUOTE + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+            lines += TWELVE_SPACE_INDENTATION + FROM_STRING_PARAM_NAME + SPACE + EQUAL + SPACE + FROM_STRING_PARAM_NAME
+                    + PERIOD + TRIM_STRING + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+            lines += TWELVE_SPACE_INDENTATION + STRING_DATA_TYPE + SQUARE_BRACKETS + SPACE + BITS_STRING_ARRAY_VAR
+                    + SPACE + EQUAL + SPACE + FROM_STRING_PARAM_NAME + PERIOD + SPLIT_STRING + OPEN_PARENTHESIS
+                    + QUOTES + COMMA + QUOTES + COMMA + SPACE + ZERO + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+            lines += TWELVE_SPACE_INDENTATION + FOR + SPACE + OPEN_PARENTHESIS + STRING_DATA_TYPE + SPACE
+                    + BIT_TEMP_VAR + SPACE + COLON + SPACE + BITS_STRING_ARRAY_VAR + CLOSE_PARENTHESIS + SPACE
+                    + OPEN_CURLY_BRACKET + NEW_LINE;
+            lines += SIXTEEN_SPACE_INDENTATION + BIT_TEMP_VAR + SPACE + EQUAL + SPACE + BIT_TEMP_VAR + PERIOD
+                    + TRIM_STRING + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+            lines += SIXTEEN_SPACE_INDENTATION + TMP_VAL + PERIOD + SET_METHOD_PREFIX + OPEN_PARENTHESIS
+                    + INTEGER_WRAPPER + PERIOD + PARSE_INT + OPEN_PARENTHESIS + BIT_TEMP_VAR + CLOSE_PARENTHESIS
+                    + CLOSE_PARENTHESIS + SEMI_COLAN + NEW_LINE;
+            lines += TWELVE_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
+            return lines;
+        } else if (attr.getAttributeType().getDataType() == BINARY) {
+            return targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + BASE64 + PERIOD
+                    + GET_DECODER + OPEN_PARENTHESIS + CLOSE_PARENTHESIS + PERIOD + DECODE + OPEN_PARENTHESIS
+                    + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN;
         } else {
             String parseFromStringMethod = getParseFromStringMethod(targetDataType,
                                                                     fromStringAttributeInfo.getAttributeType());
             return targetDataType + SPACE + TMP_VAL + SPACE + EQUAL + SPACE + parseFromStringMethod
-                    + OPEN_PARENTHESIS + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS;
+                    + OPEN_PARENTHESIS + FROM_STRING_PARAM_NAME + CLOSE_PARENTHESIS + SEMI_COLAN;
         }
     }
 
@@ -1350,15 +1388,15 @@
         for (String str : enumList) {
 
             value = enumMap.get(str);
-            method = method + TWELVE_SPACE_INDENTATION + CASE + SPACE + value + COLAN + NEW_LINE
+            method = method + TWELVE_SPACE_INDENTATION + CASE + SPACE + value + COLON + NEW_LINE
                     + SIXTEEN_SPACE_INDENTATION + RETURN + SPACE + getCapitalCase(className) + PERIOD
                     + str + SEMI_COLAN + NEW_LINE;
         }
-        method = method + TWELVE_SPACE_INDENTATION + DEFAULT + SPACE + COLAN + NEW_LINE + SIXTEEN_SPACE_INDENTATION
+        method = method + TWELVE_SPACE_INDENTATION + DEFAULT + SPACE + COLON + NEW_LINE + SIXTEEN_SPACE_INDENTATION
                 + RETURN + SPACE + NULL + SEMI_COLAN + NEW_LINE + EIGHT_SPACE_INDENTATION + CLOSE_CURLY_BRACKET
                 + NEW_LINE + FOUR_SPACE_INDENTATION + CLOSE_CURLY_BRACKET;
 
-        return getJavaDoc(OF_METHOD, getCapitalCase(className) + " for type " + attrName, false, pluginConfig)
+        return getJavaDoc(OF_METHOD, getCapitalCase(className) + FOR_TYPE + attrName, false, pluginConfig)
                 + method;
     }
 
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index 21f8d65..85e1e7e 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -237,6 +237,31 @@
     public static final String PARSE_LONG = "parseLong";
 
     /**
+     * Static attribute for base64.
+     */
+    public static final String BASE64 = "Base64";
+
+    /**
+     * Static attribute for getEncoder.
+     */
+    public static final String GET_ENCODER = "getEncoder";
+
+    /**
+     * Static attribute for encodeToString.
+     */
+    public static final String ENCODE_TO_STRING = "encodeToString";
+
+    /**
+     * Static attribute for getDecoder.
+     */
+    public static final String GET_DECODER = "getDecoder";
+
+    /**
+     * Static attribute for decode.
+     */
+    public static final String DECODE = "decode";
+
+    /**
      * Static attribute for omit null value.
      */
     public static final String OMIT_NULL_VALUE_STRING = "omitNullValues()";
@@ -322,6 +347,16 @@
     public static final String IDENTITYREF = "identityref";
 
     /**
+     * Static attribute for binary string.
+     */
+    public static final String BINARY_STRING = "binary";
+
+    /**
+     * Static attribute for bits string.
+     */
+    public static final String BITS_STRING = "bits";
+
+    /**
      * Static attribute for output variable of rpc.
      */
     public static final String RPC_INPUT_VAR_NAME = "inputVar";
@@ -342,11 +377,21 @@
     public static final String ADD = "+";
 
     /**
+     * Static attribute for single quote.
+     */
+    public static final String SINGLE_QUOTE = "\'";
+
+    /**
      * Static attribute for quotes.
      */
     public static final String QUOTES = "\"";
 
     /**
+     * Static attribute for zero.
+     */
+    public static final String ZERO = "0";
+
+    /**
      * Static attribute for ampersand.
      */
     public static final String AND = "&";
@@ -412,6 +457,21 @@
     public static final String ADD_STRING = "add";
 
     /**
+     * Static attribute for string replace syntax.
+     */
+    public static final String REPLACE_STRING = "replace";
+
+    /**
+     * Static attribute for string trim syntax.
+     */
+    public static final String TRIM_STRING = "trim";
+
+    /**
+     * Static attribute for string split syntax.
+     */
+    public static final String SPLIT_STRING = "split";
+
+    /**
      * Static attribute for from syntax.
      */
     public static final String FROM_STRING_METHOD_NAME = "fromString";
@@ -457,6 +517,11 @@
     public static final String IF = "if";
 
     /**
+     * Static attribute for "for" syntax.
+     */
+    public static final String FOR = "for";
+
+    /**
      * Static attribute for of.
      */
     public static final String OF = "of";
@@ -1103,6 +1168,11 @@
     public static final String JAVA_UTIL_OBJECTS_IMPORT_CLASS = "Objects;\n";
 
     /**
+     * Static attribute for java utilities import base64 class.
+     */
+    public static final String JAVA_UTIL_IMPORT_BASE64_CLASS = "Base64;\n";
+
+    /**
      * Static attribute for AugmentedInfo class import package.
      */
     public static final String YANG_AUGMENTED_INFO_CLASS_IMPORT_PKG = "org.onosproject.yangutils.datamodel";
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
index ef25c97..a4410a7 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BitListenerTest.java
@@ -21,6 +21,7 @@
 import org.junit.Test;
 import org.onosproject.yangutils.datamodel.YangBit;
 import org.onosproject.yangutils.datamodel.YangBits;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
 import org.onosproject.yangutils.datamodel.YangLeaf;
 import org.onosproject.yangutils.datamodel.YangModule;
@@ -168,6 +169,117 @@
     }
 
     /**
+     * Checks bit statement with typedef with referred leaf.
+     */
+    @Test
+    public void processBitTypedefReferredLeafStatement() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/BitTypedefReferredLeafStatement.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        YangTypeDef typedef = (YangTypeDef) yangNode.getChild();
+        assertThat(typedef.getName(), is("topBits"));
+
+        YangType type = typedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.BITS));
+        assertThat(type.getDataTypeName(), is("bits"));
+
+        // Check bit name map
+        Map<String, YangBit> bitNameMap = ((YangBits) type.getDataTypeExtendedInfo()).getBitNameMap();
+        assertThat(bitNameMap.size(), is(3));
+        for (Map.Entry<String, YangBit> element : bitNameMap.entrySet()) {
+            String bitName = element.getKey();
+            YangBit yangBit = element.getValue();
+            if (bitName.equals("disable-nagle")) {
+                assertThat(yangBit.getPosition(), is(0));
+            } else if (bitName.equals("auto-sense-speed")) {
+                assertThat(yangBit.getPosition(), is(1));
+            } else if (bitName.equals("Mb-only")) {
+                assertThat(yangBit.getPosition(), is(2));
+            } else {
+                throw new IOException("Invalid bit name: " + bitName);
+            }
+        }
+
+        // Check bit position map
+        Map<Integer, YangBit> bitPositionMap = ((YangBits) type.getDataTypeExtendedInfo()).getBitPositionMap();
+        assertThat(bitPositionMap.size(), is(3));
+        for (Map.Entry<Integer, YangBit> element : bitPositionMap.entrySet()) {
+            int position = element.getKey();
+            YangBit yangBit = element.getValue();
+            if (position == 0) {
+                assertThat(yangBit.getBitName(), is("disable-nagle"));
+            } else if (position == 1) {
+                assertThat(yangBit.getBitName(), is("auto-sense-speed"));
+            } else if (position == 2) {
+                assertThat(yangBit.getBitName(), is("Mb-only"));
+            } else {
+                throw new IOException("Invalid bit position: " + position);
+            }
+        }
+
+        // Check leaf reffered typedef
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getName(), is("myBits"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("topBits"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+        YangType<YangDerivedInfo> typeDerived = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+        YangDerivedInfo derivedInfo = (YangDerivedInfo) typeDerived.getDataTypeExtendedInfo();
+        YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(prevTypedef.getName(), is("topBits"));
+        YangType topType = prevTypedef.getTypeList().iterator().next();
+        assertThat(topType.getDataType(), is(YangDataTypes.BITS));
+        assertThat(topType.getDataTypeName(), is("bits"));
+        YangType<YangBits> typeBits = (YangType<YangBits>) topType;
+        YangBits bits = typeBits.getDataTypeExtendedInfo();
+
+        // Check bit name map
+        bitNameMap = bits.getBitNameMap();
+        assertThat(bitNameMap.size(), is(3));
+        for (Map.Entry<String, YangBit> element : bitNameMap.entrySet()) {
+            String bitName = element.getKey();
+            YangBit yangBit = element.getValue();
+            if (bitName.equals("disable-nagle")) {
+                assertThat(yangBit.getPosition(), is(0));
+            } else if (bitName.equals("auto-sense-speed")) {
+                assertThat(yangBit.getPosition(), is(1));
+            } else if (bitName.equals("Mb-only")) {
+                assertThat(yangBit.getPosition(), is(2));
+            } else {
+                throw new IOException("Invalid bit name: " + bitName);
+            }
+        }
+
+        // Check bit position map
+        bitPositionMap = bits.getBitPositionMap();
+        assertThat(bitPositionMap.size(), is(3));
+        for (Map.Entry<Integer, YangBit> element : bitPositionMap.entrySet()) {
+            int position = element.getKey();
+            YangBit yangBit = element.getValue();
+            if (position == 0) {
+                assertThat(yangBit.getBitName(), is("disable-nagle"));
+            } else if (position == 1) {
+                assertThat(yangBit.getBitName(), is("auto-sense-speed"));
+            } else if (position == 2) {
+                assertThat(yangBit.getBitName(), is("Mb-only"));
+            } else {
+                throw new IOException("Invalid bit position: " + position);
+            }
+        }
+    }
+
+    /**
      * Checks bit statement with union.
      */
     @Test
diff --git a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
index ec5b3fc..303a3e6 100644
--- a/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
+++ b/utils/yangutils/plugin/src/test/java/org/onosproject/yangutils/parser/impl/listeners/Decimal64ListenerTest.java
@@ -33,6 +33,7 @@
 import org.onosproject.yangutils.datamodel.YangType;
 import org.onosproject.yangutils.datamodel.YangTypeDef;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
 import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes;
@@ -56,7 +57,7 @@
     @Test
     public void processDecimal64TypeStatement() throws IOException, ParserException {
 
-        YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeStatement.yang");
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeStatement.yang");
 
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
@@ -84,7 +85,7 @@
     @Test
     public void processDecimal64TypeWithRangeStatement() throws IOException, ParserException {
 
-        YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeWithRangeStatement.yang");
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeWithRangeStatement.yang");
 
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
@@ -122,7 +123,7 @@
     @Test
     public void processDecimal64ValueSuccessfulValidation() throws IOException, ParserException, DataModelException {
 
-        YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeValidation.yang");
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeValidation.yang");
 
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
@@ -157,7 +158,7 @@
         thrown.expect(DataModelException.class);
         thrown.expectMessage("YANG file error : decimal64 validation failed.");
 
-        YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeValidation.yang");
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeValidation.yang");
 
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
@@ -191,7 +192,7 @@
         thrown.expect(ParserException.class);
         thrown.expectMessage("YANG file error : fraction-digits value should be between 1 and 18.");
 
-        manager.getDataModel("src/test/resources/Decimal64TypeInvalidMaxValueFraction.yang");
+        manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidMaxValueFraction.yang");
     }
 
     /**
@@ -202,7 +203,7 @@
         thrown.expect(ParserException.class);
         thrown.expectMessage("YANG file error : fraction-digits value should be between 1 and 18.");
 
-        manager.getDataModel("src/test/resources/Decimal64TypeInvalidMinValueFraction1.yang");
+        manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction1.yang");
     }
 
     /**
@@ -213,7 +214,7 @@
         thrown.expect(ParserException.class);
         thrown.expectMessage("YANG file error : fraction-digits value should be between 1 and 18.");
 
-        manager.getDataModel("src/test/resources/Decimal64TypeInvalidMinValueFraction2.yang");
+        manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction2.yang");
     }
 
     /**
@@ -222,7 +223,7 @@
     @Test
     public void processDecimal64TypeWithMultiValueRangeStatement() throws IOException, ParserException {
 
-        YangNode node = manager.getDataModel("src/test/resources/Decimal64TypeWithMultiValueRangeStmnt.yang");
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang");
 
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
@@ -272,7 +273,7 @@
         thrown.expect(ParserException.class);
         thrown.expectMessage("YANG file error : decimal64 validation failed.");
 
-        manager.getDataModel("src/test/resources/Decimal64TypeInvalidRangeStmnt.yang");
+        manager.getDataModel("src/test/resources/decimal64/Decimal64TypeInvalidRangeStmnt.yang");
     }
 
     /**
@@ -283,7 +284,7 @@
         thrown.expect(ParserException.class);
         thrown.expectMessage("YANG file error : a type decimal64 must have fraction-digits statement.");
 
-        manager.getDataModel("src/test/resources/Decimal64TypeWithoutFraction.yang");
+        manager.getDataModel("src/test/resources/decimal64/Decimal64TypeWithoutFraction.yang");
     }
 
     /**
@@ -292,7 +293,7 @@
     @Test
     public void processDecimal64TypedefStatement() throws IOException, ParserException {
 
-        YangNode node = manager.getDataModel("src/test/resources/Decimal64TypedefStatement.yang");
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64TypedefStatement.yang");
 
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
@@ -329,7 +330,7 @@
     @Test
     public void processDecimal64MultiTypedefStatement() throws IOException, ParserException {
 
-        YangNode node = manager.getDataModel("src/test/resources/Decimal64MultiTypedefStatement.yang");
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang");
 
         // Check whether the data model tree returned is of type module.
         assertThat((node instanceof YangModule), is(true));
@@ -345,15 +346,15 @@
         YangLeaf leafInfo = leafIterator.next();
 
         // check leaf type
-        assertThat(leafInfo.getName(), is("setFourDecimal"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("validDecimal"));
+        assertThat(leafInfo.getName(), is("lowerDecimal"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
         YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
         assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
         YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
 
         // check previous typedef
         YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
-        assertThat(prevTypedef.getName(), is("validDecimal"));
+        assertThat(prevTypedef.getName(), is("midDecimal"));
         YangType type = prevTypedef.getTypeList().iterator().next();
         assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
         derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
@@ -368,4 +369,260 @@
         YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
         assertThat(decimal64.getFractionDigit(), is(4));
     }
+
+    /**
+     * Checks decimal64 with multiple typedef with single range statement.
+     * Range value in typedef statement.
+     */
+    @Test
+    public void processDecimal64MultiTypedefRangeStatement() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check leaf type
+        assertThat(leafInfo.getName(), is("lowerDecimal"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+        YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+        assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+        YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+        // Check range restriction
+        YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+        ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+                .listIterator();
+        YangRangeInterval rangeInterval = rangeListIterator.next();
+        assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+        assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+
+        // check previous typedef
+        YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(prevTypedef.getName(), is("midDecimal"));
+        YangType type = prevTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+        derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+        // check top typedef
+        YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(topTypedef.getName(), is("topDecimal"));
+        type = topTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+        assertThat(type.getDataTypeName(), is("decimal64"));
+        YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+        YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+        assertThat(decimal64.getFractionDigit(), is(4));
+
+        // Check range restriction
+        rangeRestriction = (YangRangeRestriction) decimal64.getRangeRestrictedExtendedInfo();
+        rangeListIterator = rangeRestriction.getAscendingRangeIntervals().listIterator();
+        rangeInterval = rangeListIterator.next();
+        assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+        assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+    }
+
+    /**
+     * Checks decimal64 with multiple typedef with single range statement.
+     * Range value in leaf statement.
+     */
+    @Test
+    public void processDecimal64MultiTypedefRangeInLeafStatement() throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check leaf type
+        assertThat(leafInfo.getName(), is("lowerDecimal"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+        YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+        assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+        YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+        // Check range restriction
+        YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+        ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+                .listIterator();
+        YangRangeInterval rangeInterval = rangeListIterator.next();
+        assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+        assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+
+        // check previous typedef
+        YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(prevTypedef.getName(), is("midDecimal"));
+        YangType type = prevTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+        derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+        // check top typedef
+        YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(topTypedef.getName(), is("topDecimal"));
+        type = topTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+        assertThat(type.getDataTypeName(), is("decimal64"));
+        YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+        YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+        assertThat(decimal64.getFractionDigit(), is(4));
+    }
+
+    /**
+     * Checks decimal64 with multiple typedef with multiple range statement.
+     * Having more restricted range at leaf.
+     */
+    @Test
+    public void processDecimal64MultiTypedefMultipleRangeStatement() throws IOException, ParserException {
+
+        YangNode node = manager
+                .getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check leaf type
+        assertThat(leafInfo.getName(), is("lowerDecimal"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+        YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+        assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+        YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+        // Check range restriction
+        YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+        ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+                .listIterator();
+        YangRangeInterval rangeInterval = rangeListIterator.next();
+        assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(4.0));
+        assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(11.0));
+
+        // check previous typedef
+        YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(prevTypedef.getName(), is("midDecimal"));
+        YangType type = prevTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+        derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+        // check top typedef
+        YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(topTypedef.getName(), is("topDecimal"));
+        type = topTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+        assertThat(type.getDataTypeName(), is("decimal64"));
+        YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+        YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+        assertThat(decimal64.getFractionDigit(), is(4));
+
+        // Check range restriction
+        rangeRestriction = (YangRangeRestriction) decimal64.getRangeRestrictedExtendedInfo();
+        rangeListIterator = rangeRestriction.getAscendingRangeIntervals().listIterator();
+        rangeInterval = rangeListIterator.next();
+        assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+        assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+    }
+
+    /**
+     * Checks decimal64 with multiple typedef with multiple range statement.
+     * But having more restricted range at top of typedef.
+     */
+    @Test
+    public void processDecimal64MultiTypedefMultiInvalidRangeStatement() throws IOException, LinkerException {
+        thrown.expect(LinkerException.class);
+        thrown.expectMessage(" Range interval doesn't fall within the referred restriction ranges");
+
+        manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang");
+    }
+
+    /**
+     * Checks decimal64 with multiple typedef with max range statement.
+     */
+    @Test
+    public void processDecimal64MultiTypedefWithMaxRange() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang");
+
+        // Check whether the data model tree returned is of type module.
+        assertThat((node instanceof YangModule), is(true));
+
+        // Check whether the node type is set properly to module.
+        assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+        // Check whether the module name is set correctly.
+        YangModule yangNode = (YangModule) node;
+        assertThat(yangNode.getName(), is("Test"));
+
+        ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        // check leaf type
+        assertThat(leafInfo.getName(), is("lowerDecimal"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("midDecimal"));
+        YangType<YangDerivedInfo> derivedInfoType = (YangType<YangDerivedInfo>) leafInfo.getDataType();
+        assertThat(derivedInfoType.getDataType(), is(YangDataTypes.DERIVED));
+        YangDerivedInfo derivedInfo = (YangDerivedInfo) derivedInfoType.getDataTypeExtendedInfo();
+
+        // Check range restriction
+        YangRangeRestriction rangeRestriction = (YangRangeRestriction) derivedInfo.getResolvedExtendedInfo();
+
+        ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
+                .listIterator();
+        YangRangeInterval rangeInterval = rangeListIterator.next();
+        assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(4.0));
+        assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+
+        // check previous typedef
+        YangTypeDef prevTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(prevTypedef.getName(), is("midDecimal"));
+        YangType type = prevTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DERIVED));
+        derivedInfo = (YangDerivedInfo) type.getDataTypeExtendedInfo();
+
+        // check top typedef
+        YangTypeDef topTypedef = (YangTypeDef) derivedInfo.getReferredTypeDef();
+        assertThat(topTypedef.getName(), is("topDecimal"));
+        type = topTypedef.getTypeList().iterator().next();
+        assertThat(type.getDataType(), is(YangDataTypes.DECIMAL64));
+        assertThat(type.getDataTypeName(), is("decimal64"));
+        YangType<YangDecimal64> decimal64Type = (YangType<YangDecimal64>) type;
+        YangDecimal64 decimal64 = decimal64Type.getDataTypeExtendedInfo();
+        assertThat(decimal64.getFractionDigit(), is(4));
+
+        // Check range restriction
+        rangeRestriction = (YangRangeRestriction) decimal64.getRangeRestrictedExtendedInfo();
+        rangeListIterator = rangeRestriction.getAscendingRangeIntervals().listIterator();
+        rangeInterval = rangeListIterator.next();
+        assertThat(((YangDecimal64) rangeInterval.getStartValue()).getValue().doubleValue(), is(1.0));
+        assertThat(((YangDecimal64) rangeInterval.getEndValue()).getValue().doubleValue(), is(12.0));
+    }
 }
diff --git a/utils/yangutils/plugin/src/test/resources/BitTypedefReferredLeafStatement.yang b/utils/yangutils/plugin/src/test/resources/BitTypedefReferredLeafStatement.yang
new file mode 100644
index 0000000..cda6381
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/BitTypedefReferredLeafStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef topBits { 
+        type bits {
+             bit disable-nagle {
+                 position 0;
+             }
+             bit auto-sense-speed {
+                 position 1;
+             }
+             bit Mb-only {
+                 position 2;
+             }
+         }
+    }
+
+    leaf myBits {
+        type topBits;
+    }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang
new file mode 100644
index 0000000..966b387
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiInvalidRangeStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topDecimal {
+         type decimal64 {
+            fraction-digits 4;
+            range 4..11;
+         }
+    }
+
+    typedef midDecimal {
+         type topDecimal;
+    }
+
+    leaf lowerDecimal {
+         type midDecimal {
+            range 1..12;
+         }
+    }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang
new file mode 100644
index 0000000..76f215a
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefMultiRangeStatement.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topDecimal {
+         type decimal64 {
+            fraction-digits 4;
+            range 1..12;
+         }
+    }
+
+    typedef midDecimal {
+         type topDecimal;
+    }
+
+    leaf lowerDecimal {
+         type midDecimal {
+            range 4..11;
+         }
+    }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang
new file mode 100644
index 0000000..eea48f4
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeInLeafStatement.yang
@@ -0,0 +1,21 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topDecimal {
+         type decimal64 {
+            fraction-digits 4;
+         }
+    }
+
+    typedef midDecimal {
+         type topDecimal;
+    }
+
+    leaf lowerDecimal {
+         type midDecimal {
+            range 1..12;
+         }
+    }
+}
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang
similarity index 69%
copy from utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
copy to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang
index fdce08e..b4c0a36 100644
--- a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefRangeStatement.yang
@@ -6,14 +6,15 @@
     typedef topDecimal {
          type decimal64 {
             fraction-digits 4; 
+            range 1..12;
          }
     }
 
-    typedef validDecimal {
+    typedef midDecimal {
          type topDecimal;
     }
 
-    leaf setFourDecimal {
-         type validDecimal;
+    leaf lowerDecimal {
+         type midDecimal;
     } 
 }
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang
similarity index 73%
rename from utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang
index fdce08e..8682aac 100644
--- a/utils/yangutils/plugin/src/test/resources/Decimal64MultiTypedefStatement.yang
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefStatement.yang
@@ -9,11 +9,11 @@
          }
     }
 
-    typedef validDecimal {
+    typedef midDecimal {
          type topDecimal;
     }
 
-    leaf setFourDecimal {
-         type validDecimal;
+    leaf lowerDecimal {
+         type midDecimal;
     } 
 }
diff --git a/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang
new file mode 100644
index 0000000..405d08c
--- /dev/null
+++ b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64MultiTypedefWithMaxRange.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+
+    typedef topDecimal {
+         type decimal64 {
+            fraction-digits 4;
+            range 1..12;
+         }
+    }
+
+    typedef midDecimal {
+         type topDecimal;
+    }
+
+    leaf lowerDecimal {
+         type midDecimal {
+            range 4..max;
+         }
+    } 
+}
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMaxValueFraction.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMaxValueFraction.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMaxValueFraction.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMaxValueFraction.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction1.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction1.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction1.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction1.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction2.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction2.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidMinValueFraction2.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidMinValueFraction2.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidRangeStmnt.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidRangeStmnt.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeInvalidRangeStmnt.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeInvalidRangeStmnt.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeStatement.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeStatement.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeValidation.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeValidation.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeValidation.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeValidation.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeWithMultiValueRangeStmnt.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeWithMultiValueRangeStmnt.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithMultiValueRangeStmnt.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeWithRangeStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithRangeStatement.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeWithRangeStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithRangeStatement.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypeWithoutFraction.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithoutFraction.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypeWithoutFraction.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypeWithoutFraction.yang
diff --git a/utils/yangutils/plugin/src/test/resources/Decimal64TypedefStatement.yang b/utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypedefStatement.yang
similarity index 100%
rename from utils/yangutils/plugin/src/test/resources/Decimal64TypedefStatement.yang
rename to utils/yangutils/plugin/src/test/resources/decimal64/Decimal64TypedefStatement.yang
diff --git a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
index 10b6c11..5b65dff 100644
--- a/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
+++ b/utils/yangutils/plugin/src/test/resources/interfileietf/ietf-te-topology.yang
@@ -1723,7 +1723,6 @@
        uses tet:te-link-state-derived;
      }
 
-     
      augment "/te-link-event/te-link-attributes/underlay" {
        description "Add state attributes to te-link underlay.";
        uses te-link-state-underlay-attributes;