[ONOS-4063 to 68] Intra YANG file Linking Implementation and Intra YANG file Linking Framework

Change-Id: I06e602c351ab54178bf90b8676af71a70e42371f
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasResolutionInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasResolutionInfo.java
new file mode 100644
index 0000000..85eaa51
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/HasResolutionInfo.java
@@ -0,0 +1,111 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+import java.util.List;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+
+/**
+ * Abstraction of YANG dependency resolution information. Abstracted to obtain the
+ * resolution information.
+ */
+public interface HasResolutionInfo {
+
+    /**
+     * Returns unresolved resolution list.
+     *
+     * @return unresolved resolution list
+     */
+    List<YangResolutionInfo> getUnresolvedResolutionList();
+
+    /**
+     * Add to the resolution list.
+     *
+     * @param resolutionInfo resolution information
+     */
+    void addToResolutionList(YangResolutionInfo resolutionInfo);
+
+    /**
+     * Creates resolution list.
+     *
+     * @param resolutionList resolution list
+     */
+    void setResolutionList(List<YangResolutionInfo> resolutionList);
+
+    /**
+     * Returns unresolved imported list.
+     *
+     * @return unresolved imported list
+     */
+    List<YangImport> getImportList();
+
+    /**
+     * Add to the import list.
+     *
+     * @param yangImport import to be added
+     */
+    void addToImportList(YangImport yangImport);
+
+    /**
+     * Create import list.
+     *
+     * @param importList import list
+     */
+    void setImportList(List<YangImport> importList);
+
+    /**
+     * Returns unresolved include list.
+     *
+     * @return unresolved include list
+     */
+    List<YangInclude> getIncludeList();
+
+    /**
+     * Add to the include list.
+     *
+     * @param yangInclude include to be added
+     */
+    void addToIncludeList(YangInclude yangInclude);
+
+    /**
+     * Create include list.
+     *
+     * @param includeList include list
+     */
+    void setIncludeList(List<YangInclude> includeList);
+
+    /**
+     * Returns prefix of resolution root node.
+     *
+     * @return prefix resolution root node prefix
+     */
+    String getPrefix();
+
+    /**
+     * Set prefix of resolution list root node.
+     *
+     * @param prefix resolution root node prefix
+     */
+    void setPrefix(String prefix);
+
+    /**
+     * Resolve self file linking.
+     *
+     * @throws DataModelException a violation in data model rule
+     */
+    void resolveSelfFileLinking() throws DataModelException;
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/ResolutionType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/ResolutionType.java
new file mode 100644
index 0000000..6ee67fb
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/ResolutionType.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+/**
+ * ENUM to identify the YANG resolution type.
+ */
+public enum ResolutionType {
+    /**
+     * Identifies that resolution is for typedef.
+     */
+    TYPEDEF_RESOLUTION,
+
+    /**
+     * Identifies that resolution is for grouping.
+     */
+    GROUPING_RESOLUTION;
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/Resolvable.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/Resolvable.java
new file mode 100644
index 0000000..4c92b97
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/Resolvable.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+/**
+ * Abstraction of YANG resolvable information. Abstracted to obtain the
+ * information required for linking resolution.
+ */
+public interface Resolvable {
+
+    /**
+     * Returns the status of resolution. If completely resolved returns enum
+     * value "RESOLVED", if not returns "UNRESOLVED", in case reference of
+     * grouping/typedef is added to uses/type but it's not resolved
+     * "PARTIALLY_RESOLVED" is returned.
+     *
+     * @return status of resolution
+     */
+    ResolvableStatus getResolvableStatus();
+
+    /**
+     * Set the status of type/uses resolution. If completely resolved set enum
+     * value "RESOLVED", if not set it to "UNRESOLVED", in case reference of
+     * grouping/typedef is added to uses/type but it's not resolved
+     * "PARTIALLY_RESOLVED" should be set.
+     *
+     * @param resolvableStatus status of resolution
+     */
+    void setResolvableStatus(ResolvableStatus resolvableStatus);
+
+    /**
+     * Resolves the linking.
+     */
+    void resolve();
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/ResolvableStatus.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/ResolvableStatus.java
new file mode 100644
index 0000000..c8a556b
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/ResolvableStatus.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+/**
+ * Represents the status of resolvable entity.
+ */
+public enum ResolvableStatus {
+
+    /**
+    * Identifies that resolvable entity is resolved.
+    */
+    RESOLVED,
+
+    /**
+     * Identifies that resolvable entity is unresolved.
+     */
+    UNRESOLVED,
+
+    /**
+     * Identifies that resolvable entity is partially resolved.
+     */
+    PARTIALLY_RESOLVED;
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
new file mode 100644
index 0000000..53655cd
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedInfo.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+/**
+ * Maintains the derived information.
+ *
+ * @param <T> extended information.
+ */
+public class YangDerivedInfo<T> {
+
+    /**
+     * YANG typedef reference.
+     */
+    private YangTypeDef referredTypeDef;
+
+    /**
+     * Resolved additional information about data type after linking, example
+     * restriction info, named values, etc. The extra information is based
+     * on the data type. Based on the data type, the extended info can vary.
+     */
+    private T resolvedExtendedInfo;
+
+    /**
+     * Additional information about data type, example restriction info, named
+     * values, etc. The extra information is based on the data type. Based on
+     * the data type, the extended info can vary.
+     */
+    private T extendedInfo;
+
+    /**
+     * Returns the referred typedef reference.
+     *
+     * @return referred typedef reference
+     */
+    public YangTypeDef getReferredTypeDef() {
+        return referredTypeDef;
+    }
+
+    /**
+     * Set the referred typedef reference.
+     *
+     * @param referredTypeDef referred typedef reference
+     */
+    public void setReferredTypeDef(YangTypeDef referredTypeDef) {
+        this.referredTypeDef = referredTypeDef;
+    }
+
+    /**
+     * Returns resolved extended information after successful linking.
+     *
+     * @return resolved extended information
+     */
+    public T getResolvedExtendedInfo() {
+        return resolvedExtendedInfo;
+    }
+
+    /**
+     * Set resolved extended information after successful linking.
+     *
+     * @param resolvedExtendedInfo resolved extended information
+     */
+    public void setResolvedExtendedInfo(T resolvedExtendedInfo) {
+        this.resolvedExtendedInfo = resolvedExtendedInfo;
+    }
+
+    /**
+     * Returns extended information.
+     *
+     * @return extended information
+     */
+    public T getExtendedInfo() {
+        return extendedInfo;
+    }
+
+    /**
+     * Set extended information.
+     *
+     * @param extendedInfo extended information
+     */
+    public void setExtendedInfo(T extendedInfo) {
+        this.extendedInfo = extendedInfo;
+    }
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedType.java
deleted file mode 100644
index e235480..0000000
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangDerivedType.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2016 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.onosproject.yangutils.datamodel;
-
-import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.parser.Parsable;
-import org.onosproject.yangutils.utils.YangConstructType;
-
-/*-
- * Reference RFC 6020.
- *
- * The typedef Statement
- *
- * The "typedef" statement defines a new type that may be used locally
- * in the module, in modules or submodules which include it, and by
- * other modules that import from it. The new type is called the
- * "derived type", and the type from which it was derived is called
- * the "base type".  All derived types can be traced back to a YANG
- * built-in type.
- *
- * The "typedef" statement's argument is an identifier that is the name
- * of the type to be defined, and MUST be followed by a block of
- * sub-statements that holds detailed typedef information.
- *
- * The name of the type MUST NOT be one of the YANG built-in types.  If
- * the typedef is defined at the top level of a YANG module or
- * submodule, the name of the type to be defined MUST be unique within
- * the module.
- */
-/**
- * Derived type information.
- */
-public class YangDerivedType implements Parsable {
-
-    /**
-     * All derived types can be traced back to a YANG built-in type.
-     */
-    private YangDataTypes effectiveYangBuiltInType;
-
-    /**
-     * Base type from which the current type is derived.
-     */
-    private YangType<?> baseType;
-
-    /**
-     * Default constructor.
-     */
-    public YangDerivedType() {
-    }
-
-    /**
-     * Get the effective YANG built-in type of the derived data type.
-     *
-     * @return effective YANG built-in type of the derived data type
-     */
-    public YangDataTypes getEffectiveYangBuiltInType() {
-        return effectiveYangBuiltInType;
-    }
-
-    /**
-     * Set the effective YANG built-in type of the derived data type.
-     *
-     * @param builtInType effective YANG built-in type of the derived data type
-     */
-    public void setEffectiveYangBuiltInType(YangDataTypes builtInType) {
-        effectiveYangBuiltInType = builtInType;
-    }
-
-    /**
-     * Get the base type information.
-     *
-     * @return base type information
-     */
-    public YangType<?> getBaseType() {
-        return baseType;
-    }
-
-    /**
-     * Get the base type information.
-     *
-     * @param baseType base type information
-     */
-    public void setBaseType(YangType<?> baseType) {
-        this.baseType = baseType;
-    }
-
-    /**
-     * Get the parsable type.
-     */
-    @Override
-    public YangConstructType getYangConstructType() {
-        return YangConstructType.DERIVED;
-    }
-
-    /**
-     * TODO.
-     */
-    @Override
-    public void validateDataOnEntry() throws DataModelException {
-        // TODO Auto-generated method stub
-
-    }
-
-    /**
-     * TODO.
-     */
-    @Override
-    public void validateDataOnExit() throws DataModelException {
-        // TODO Auto-generated method stub
-
-    }
-
-}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
index a6e81f0..6739197 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangImport.java
@@ -75,6 +75,11 @@
     private String prefixId;
 
     /**
+     * Resolution information root node which is also the data model root node.
+     */
+    private HasResolutionInfo resolutionInfoNode;
+
+    /**
      * Reference:RFC 6020.
      *
      * The import's "revision-date" statement is used to specify the exact
@@ -177,4 +182,22 @@
         // TODO auto-generated method stub, to be implemented by parser
 
     }
+
+    /**
+     * Returns the resolution information node.
+     *
+     * @return the resolution information node
+     */
+    public HasResolutionInfo getResolutionInfoNode() {
+        return resolutionInfoNode;
+    }
+
+    /**
+     * Set the dresolution information node.
+     *
+     * @param resolutionInfoNode the resolution information node
+     */
+    public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) {
+        this.resolutionInfoNode = resolutionInfoNode;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
index 917a0d3..3aeb68b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangInclude.java
@@ -51,6 +51,11 @@
     private String revision;
 
     /**
+     * Resolution information root node which is also the data model root node.
+     */
+    private HasResolutionInfo resolutionInfoNode;
+
+    /**
      * Default constructor.
      */
     public YangInclude() {
@@ -124,4 +129,21 @@
 
     }
 
+    /**
+     * Returns the resolution information node.
+     *
+     * @return the resolution information node
+     */
+    public HasResolutionInfo getResolutionInfoNode() {
+        return resolutionInfoNode;
+    }
+
+    /**
+     * Set the dresolution information node.
+     *
+     * @param resolutionInfoNode the resolution information node
+     */
+    public void setResolutionInfoNode(HasResolutionInfo resolutionInfoNode) {
+        this.resolutionInfoNode = resolutionInfoNode;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
index 13d5e66..fdd7d08 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangModule.java
@@ -17,12 +17,12 @@
 
 import java.util.LinkedList;
 import java.util.List;
-
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.utils.YangConstructType;
 
 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
 
 /*-
  * Reference:RFC 6020.
@@ -68,7 +68,7 @@
  * Data model node to maintain information defined in YANG module.
  */
 public class YangModule extends YangNode
-        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector {
+        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo {
 
     /**
      * Name of the module.
@@ -185,16 +185,19 @@
      * matching "typedef" or "grouping" statement among the immediate
      * sub-statements of each ancestor statement.
      */
-    /**
-     * List of nodes which require nested reference resolution.
-     */
-    private List<YangNode> nestedReferenceResoulutionList;
+    private List<YangResolutionInfo> unresolvedResolutionList;
 
     /**
      * Create a YANG node of module type.
      */
     public YangModule() {
+
         super(YangNodeType.MODULE_NODE);
+        unresolvedResolutionList = new LinkedList<YangResolutionInfo>();
+        importList = new LinkedList<YangImport>();
+        includeList = new LinkedList<YangInclude>();
+        listOfLeaf = new LinkedList<YangLeaf>();
+        listOfLeafList = new LinkedList<YangLeafList>();
     }
 
     /**
@@ -265,28 +268,17 @@
     }
 
     /**
-     * prevent setting the import list from outside.
-     *
-     * @param importList the import list to set
-     */
-    private void setImportList(List<YangImport> importList) {
-        this.importList = importList;
-    }
-
-    /**
      * Add the imported module information to the import list.
      *
      * @param importedModule module being imported
      */
-    public void addImportedInfo(YangImport importedModule) {
-
-        if (getImportList() == null) {
-            setImportList(new LinkedList<YangImport>());
-        }
-
+    public void addToImportList(YangImport importedModule) {
         getImportList().add(importedModule);
+    }
 
-        return;
+    @Override
+    public void setImportList(List<YangImport> importList) {
+        this.importList = importList;
     }
 
     /**
@@ -299,27 +291,17 @@
     }
 
     /**
-     * Set the list of included sub modules.
-     *
-     * @param includeList the included list to set
-     */
-    private void setIncludeList(List<YangInclude> includeList) {
-        this.includeList = includeList;
-    }
-
-    /**
      * Add the included sub module information to the include list.
      *
      * @param includeModule submodule being included
      */
-    public void addIncludedInfo(YangInclude includeModule) {
-
-        if (getIncludeList() == null) {
-            setIncludeList(new LinkedList<YangInclude>());
-        }
-
+    public void addToIncludeList(YangInclude includeModule) {
         getIncludeList().add(includeModule);
-        return;
+    }
+
+    @Override
+    public void setIncludeList(List<YangInclude> includeList) {
+        this.includeList = includeList;
     }
 
     /**
@@ -333,25 +315,12 @@
     }
 
     /**
-     * Set the list of leaf in module.
-     *
-     * @param leafsList the list of leaf to set
-     */
-    private void setListOfLeaf(List<YangLeaf> leafsList) {
-        listOfLeaf = leafsList;
-    }
-
-    /**
      * Add a leaf in module.
      *
      * @param leaf the leaf to be added
      */
     @Override
     public void addLeaf(YangLeaf leaf) {
-        if (getListOfLeaf() == null) {
-            setListOfLeaf(new LinkedList<YangLeaf>());
-        }
-
         getListOfLeaf().add(leaf);
     }
 
@@ -366,25 +335,12 @@
     }
 
     /**
-     * Set the list of leaf-list in module.
-     *
-     * @param listOfLeafList the list of leaf-list to set
-     */
-    private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
-        this.listOfLeafList = listOfLeafList;
-    }
-
-    /**
      * Add a leaf-list in module.
      *
      * @param leafList the leaf-list to be added
      */
     @Override
     public void addLeafList(YangLeafList leafList) {
-        if (getListOfLeafList() == null) {
-            setListOfLeafList(new LinkedList<YangLeafList>());
-        }
-
         getListOfLeafList().add(leafList);
     }
 
@@ -442,6 +398,14 @@
         this.prefix = prefix;
     }
 
+    @Override
+    public void resolveSelfFileLinking() throws DataModelException {
+        // Get the list to be resolved.
+        List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
+        // Resolve linking for a resolution list.
+        resolveLinkingForResolutionList(resolutionList, this);
+    }
+
     /**
      * Get the textual reference.
      *
@@ -499,37 +463,6 @@
     }
 
     /**
-     * Get the list of nested reference's which required resolution.
-     *
-     * @return list of nested reference's which required resolution
-     */
-    public List<YangNode> getNestedReferenceResoulutionList() {
-        return nestedReferenceResoulutionList;
-    }
-
-    /**
-     * Set list of nested reference's which requires resolution.
-     *
-     * @param nestedReferenceResoulutionList list of nested reference's which
-     *            requires resolution
-     */
-    private void setNestedReferenceResoulutionList(List<YangNode> nestedReferenceResoulutionList) {
-        this.nestedReferenceResoulutionList = nestedReferenceResoulutionList;
-    }
-
-    /**
-     * Set list of nested reference's which requires resolution.
-     *
-     * @param nestedReference nested reference which requires resolution
-     */
-    public void addToNestedReferenceResoulutionList(YangNode nestedReference) {
-        if (getNestedReferenceResoulutionList() == null) {
-            setNestedReferenceResoulutionList(new LinkedList<YangNode>());
-        }
-        getNestedReferenceResoulutionList().add(nestedReference);
-    }
-
-    /**
      * Returns the type of the parsed data.
      *
      * @return returns MODULE_DATA
@@ -565,31 +498,6 @@
          */
     }
 
-    /**
-     * Add a type to resolve the nested references.
-     *
-     * @param node grouping or typedef node which needs to be resolved
-     * @throws DataModelException data model exception
-     */
-    public static void addToResolveList(YangNode node) throws DataModelException {
-        /* get the module node to add maintain the list of nested reference */
-        YangModule module;
-        YangNode curNode = node;
-        while (curNode.getNodeType() != YangNodeType.MODULE_NODE) {
-            curNode = curNode.getParent();
-            if (curNode == null) {
-                break;
-            }
-        }
-        if (curNode == null) {
-            throw new DataModelException("Datamodel tree is not correct");
-        }
-
-        module = (YangModule) curNode;
-        module.addToNestedReferenceResoulutionList(node);
-        return;
-    }
-
     @Override
     public void detectCollidingChild(String identifierName, YangConstructType dataType) throws DataModelException {
         // Asks helper to detect colliding child.
@@ -601,4 +509,18 @@
         // Not required as module doesn't have any parent.
     }
 
+    @Override
+    public List<YangResolutionInfo> getUnresolvedResolutionList() {
+        return unresolvedResolutionList;
+    }
+
+    @Override
+    public void addToResolutionList(YangResolutionInfo resolutionInfo) {
+        unresolvedResolutionList.add(resolutionInfo);
+    }
+
+    @Override
+    public void setResolutionList(List<YangResolutionInfo> resolutionList) {
+        unresolvedResolutionList = resolutionList;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeIdentifier.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeIdentifier.java
index 116ee7a..2f7839b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeIdentifier.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangNodeIdentifier.java
@@ -45,7 +45,7 @@
     /**
      * Set name of the node identifier.
      *
-     * @param name node identifier name
+     * @param name name of the node identifier
      */
     public void setName(String name) {
         this.name = name;
@@ -54,7 +54,7 @@
     /**
      * Returns prefix of the node identifier.
      *
-     * @return prefix of the node identifier
+     * @return name of the node identifier
      */
     public String getPrefix() {
         return prefix;
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangResolutionInfo.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangResolutionInfo.java
new file mode 100644
index 0000000..de65bb4
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangResolutionInfo.java
@@ -0,0 +1,640 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.datamodel;
+
+import java.util.Stack;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+
+/**
+ * Resolution object which will be resolved by linker.
+ */
+public class YangResolutionInfo<T> {
+
+    // Prefix associated with the linking.
+    private String prefix;
+
+    // Parsable node for which resolution is to be performed.
+    private T entityToResolve;
+
+    // Holder of the YANG construct for which resolution has to be carried out.
+    private YangNode holderOfEntityToResolve;
+
+    // Error Line number.
+    private int lineNumber;
+
+    // Error character position.
+    private int charPosition;
+
+    // Status of resolution.
+    private boolean isResolved;
+
+    /*
+     * Stack for type/uses is maintained for hierarchical references, this
+     * is used during resolution.
+     */
+    private Stack<T> partialResolvedStack;
+
+    // Flag to indicate whether more references are detected.
+    private boolean isMoreReferenceDetected;
+
+    // Module/Sub-module prefix.
+    private String resolutionInfoRootNodePrefix;
+
+    /**
+     * Create a resolution information object.
+     */
+    private YangResolutionInfo() {
+
+    }
+
+    /**
+     * Creates a resolution information object with all the inputs.
+     *
+     * @param dataNode current parsable data node
+     * @param resolutionType type of resolution whether grouping/typedef
+     * @param holderNode parent YANG node
+     * @param prefix imported module prefix
+     * @param lineNumber error line number
+     * @param charPositionInLine error character position in line
+     */
+    public YangResolutionInfo(T dataNode, ResolutionType resolutionType,
+                              YangNode holderNode, String prefix, int lineNumber,
+                              int charPositionInLine) {
+        this.setHolderOfEntityToResolve(holderNode);
+        this.setEntityToResolve(dataNode);
+        this.setPrefix(prefix);
+        this.setLineNumber(lineNumber);
+        this.setCharPosition(charPositionInLine);
+        setPartialResolvedStack(new Stack<T>());
+    }
+
+    /**
+     * Creates a resolution information object with all the inputs except prefix.
+     *
+     * @param dataNode current parsable data node
+     * @param resolutionType type of resolution whether grouping/typedef
+     * @param holderNode parent YANG node
+     * @param lineNumber error line number
+     * @param charPositionInLine error character position in line
+     */
+    public YangResolutionInfo(T dataNode, ResolutionType resolutionType,
+                              YangNode holderNode, int lineNumber,
+                              int charPositionInLine) {
+        this.setHolderOfEntityToResolve(holderNode);
+        this.setEntityToResolve(dataNode);
+        this.setLineNumber(lineNumber);
+        this.setCharPosition(charPositionInLine);
+    }
+
+    /**
+     * Resolve linking with all the ancestors node for a resolution info.
+     *
+     * @param resolutionInfoNodePrefix module/sub-module prefix
+     * @throws DataModelException DataModelException a violation of data model rules
+     */
+    public void resolveLinkingForResolutionInfo(String resolutionInfoNodePrefix)  throws DataModelException {
+
+        this.resolutionInfoRootNodePrefix = resolutionInfoNodePrefix;
+
+        // Current node to resolve, it can be a YANG type or YANG uses.
+        T entityToResolve = getEntityToResolve();
+
+        // Check if linking is already done
+        if (entityToResolve instanceof Resolvable) {
+            Resolvable resolvable = (Resolvable) entityToResolve;
+            if (resolvable.getResolvableStatus() == ResolvableStatus.RESOLVED ||
+                    resolvable.getResolvableStatus() == ResolvableStatus.PARTIALLY_RESOLVED) {
+                return;
+            }
+        } else {
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+        }
+
+        // Push the initial YANG type to the stack.
+        getPartialResolvedStack().push(entityToResolve);
+
+        // Get holder of entity to resolve
+        YangNode curNode = getHolderOfEntityToResolve();
+
+        resolveLinkingWithAncestors(curNode);
+    }
+
+    /**
+     * Resolves linking with ancestors.
+     *
+     * @param curNode current node for which ancestors to be checked
+     * @throws DataModelException a violation of data model rules
+     */
+    private void resolveLinkingWithAncestors(YangNode curNode) throws DataModelException {
+
+        while (curNode != null) {
+            YangNode node = curNode.getChild();
+            if (resolveLinkingForNodesChildAndSibling(node, curNode)) {
+                return;
+            }
+            curNode = curNode.getParent();
+        }
+
+        // If curNode is null, it indicates an error condition in YANG file.
+        DataModelException dataModelException = new DataModelException("YANG file error: Unable to find base " +
+                "typedef/grouping for given type/uses");
+        dataModelException.setLine(getLineNumber());
+        dataModelException.setCharPosition(getCharPosition());
+        throw dataModelException;
+    }
+
+    /**
+     * Resolves linking for a node child and siblings.
+     *
+     * @param node current node
+     * @param parentNode parent node of current node
+     * @return flag to indicate whether resolution is done
+     * @throws DataModelException
+     */
+    private boolean resolveLinkingForNodesChildAndSibling(YangNode node, YangNode parentNode)
+            throws DataModelException {
+        while ((node != null)) {
+            isMoreReferenceDetected = false;
+            // Check if node is of type, typedef or grouping
+            if (isNodeOfResolveType(node)) {
+                if (resolveLinkingForNode(node, parentNode)) {
+                    return true;
+                }
+            }
+            if (isMoreReferenceDetected) {
+                /*
+                 * If more reference are present, tree traversal must start
+                 * from first child again, to check the availability of
+                 * typedef/grouping.
+                 */
+                node = parentNode.getChild();
+            } else {
+                node = node.getNextSibling();
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Resolves linking for a node.
+     *
+     * @param node current node
+     * @param parentNode parent node of current node
+     * @return flag to indicate whether resolution is done
+     * @throws DataModelException a violation of data model rules
+     */
+    private boolean resolveLinkingForNode(YangNode node, YangNode parentNode) throws
+            DataModelException {
+        /*
+         * Check if name of node name matches with the entity name
+         * under resolution.
+         */
+        if (isNodeNameSameAsResolutionInfoName(node)) {
+            // Add reference of entity to the node under resolution.
+            addReferredEntityLink(node);
+            // Check if referred entity has further reference to uses/type.
+            if (!(isMoreReferencePresent(node))) {
+                // Resolve all the entities in stack.
+                resolveStackAndAddToStack(node);
+                return true;
+            } else {
+                // Add referred type/uses to the stack.
+                addToPartialResolvedStack(node);
+                /*
+                 * Check whether referred type is resolved, partially resolved
+                 * or unresolved.
+                 */
+                if (isReferenceFullyResolved()) {
+                    // Resolve the stack which is complete.
+                    resolveCompleteStack();
+                    return true;
+                } else if (isReferencePartiallyResolved()) {
+                    /*
+                     * Update the resolution type to partially resolved for all
+                     * type/uses in stack
+                     */
+                    updateResolutionTypeToPartial();
+                    return true;
+                } else {
+                /*
+                 * Check if prefix is present to find that the derived
+                 * reference is for intra file or inter file, if it's
+                 * inter-file return and stop further processing.
+                 */
+                    if (isExternalPrefixPresent(node)) {
+                        /*
+                         * Update the resolution type to partially resolved for all
+                         * type/uses in stack
+                         */
+                        updateResolutionTypeToPartial();
+                        return true;
+                    } else {
+                    /*
+                     * If prefix is not present it indicates intra-file
+                     * dependency in this case set the node back to first
+                     * child, as referred entity may appear in any order
+                     * and continue with the resolution.
+                     */
+                        isMoreReferenceDetected = true;
+                        return false;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Update resolution type to partial for all type/uses in stack.
+     *
+     * @throws DataModelException a violation of data model rules
+     */
+    private void updateResolutionTypeToPartial() throws DataModelException {
+        // For all entries in stack calls for the resolution in type/uses.
+        for (T entity:getPartialResolvedStack()) {
+            if (!(entity instanceof Resolvable)) {
+                throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+            }
+            if (((Resolvable) entity).getResolvableStatus() == ResolvableStatus.UNRESOLVED) {
+                // Set the resolution status in inside the type/uses.
+                ((Resolvable) entity).setResolvableStatus(ResolvableStatus.PARTIALLY_RESOLVED);
+            }
+        }
+    }
+
+    /**
+     * Add referred type/uses to the stack and resolve the stack.
+     *
+     * @param node typedef/grouping node
+     * @throws DataModelException a violation of data model rules
+     */
+    private void resolveStackAndAddToStack(YangNode node) throws DataModelException {
+        if (getEntityToResolve() instanceof YangType) {
+            // Add to the stack only for YANG typedef.
+            getPartialResolvedStack().push((T) ((YangTypeDef) node).getDataType());
+        }
+        // Don't add to stack in case of YANG grouping.
+
+        // Resolve the complete stack.
+        resolveCompleteStack();
+    }
+
+    /**
+     * Check if the referred type/uses is partially resolved.
+     *
+     * @return true if reference is partially resolved, otherwise false
+     */
+    private boolean isReferencePartiallyResolved() {
+        if (getPartialResolvedStack().peek() instanceof YangType) {
+            /*
+             * Checks if type is partially resolved.
+             */
+            if (((YangType) getPartialResolvedStack().peek()).getResolvableStatus() ==
+                    ResolvableStatus.PARTIALLY_RESOLVED) {
+                return true;
+            }
+        } else if (getPartialResolvedStack().peek() instanceof YangUses) {
+            if (((YangUses) getPartialResolvedStack().peek()).getResolvableStatus() ==
+                    ResolvableStatus.PARTIALLY_RESOLVED) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Check if the referred type/uses is resolved.
+     *
+     * @return true if reference is resolved, otherwise false
+     */
+    private boolean isReferenceFullyResolved() {
+        if (getPartialResolvedStack().peek() instanceof YangType) {
+            /*
+             * Checks if type is partially resolved.
+             */
+            if (((YangType) getPartialResolvedStack().peek()).getResolvableStatus() ==
+                    ResolvableStatus.RESOLVED) {
+                return true;
+            }
+        } else if (getPartialResolvedStack().peek() instanceof YangUses) {
+            if (((YangUses) getPartialResolvedStack().peek()).getResolvableStatus() ==
+                    ResolvableStatus.RESOLVED) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Check if node is of resolve type i.e. of type typedef or grouping.
+     *
+     * @param node typedef/grouping node
+     * @return true if node is of resolve type otherwise false
+     * @throws DataModelException a violation of data model rules
+     */
+    private boolean isNodeOfResolveType(YangNode node) throws DataModelException {
+        if (getPartialResolvedStack().peek() instanceof YangType && entityToResolve instanceof YangType) {
+            if (node instanceof YangTypeDef) {
+                return true;
+            }
+        } else if (getPartialResolvedStack().peek() instanceof YangUses && entityToResolve instanceof YangUses) {
+            if (node instanceof YangGrouping) {
+                return true;
+            }
+        } else {
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+        }
+        return false;
+    }
+
+
+    /**
+     * Check if node name is same as name in resolution info, i.e. name of
+     * typedef/grouping is same as name of type/uses.
+     *
+     * @param node typedef/grouping node
+     * @return true if node name is same as name in resolution info, otherwise
+     * false
+     * @throws DataModelException a violation of data model rules
+     */
+    private boolean isNodeNameSameAsResolutionInfoName(YangNode node) throws DataModelException {
+        if (getPartialResolvedStack().peek() instanceof YangType) {
+            if (node.getName().equals(((YangType<?>) getPartialResolvedStack().peek()).getDataTypeName())) {
+                return true;
+            }
+        } else if (getPartialResolvedStack().peek() instanceof YangUses) {
+            if (node.getName().equals(((YangUses) getPartialResolvedStack().peek()).getName())) {
+                return true;
+            }
+        } else {
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+        }
+        return false;
+    }
+
+    /**
+     * Add reference of grouping/typedef in uses/type.
+     *
+     * @param node grouping/typedef node
+     * @throws DataModelException a violation of data model rules
+     */
+    private void addReferredEntityLink(YangNode node) throws DataModelException {
+        if (getPartialResolvedStack().peek() instanceof YangType) {
+            YangDerivedInfo<?> derivedInfo = (YangDerivedInfo<?>) ((YangType<?>) getPartialResolvedStack().peek())
+                    .getDataTypeExtendedInfo();
+            derivedInfo.setReferredTypeDef((YangTypeDef) node);
+        } else if (getPartialResolvedStack().peek() instanceof YangUses) {
+            ((YangUses) getPartialResolvedStack().peek()).setRefGroup((YangGrouping) node);
+        } else {
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+        }
+    }
+
+    /**
+     * Checks if typedef/grouping has further reference to type/typedef.
+     *
+     * @param node grouping/typedef node
+     * @return true if referred entity is resolved, otherwise false
+     * @throws DataModelException a violation of data model rules
+     */
+    private boolean isMoreReferencePresent(YangNode node) throws DataModelException {
+        if (getEntityToResolve() instanceof YangType) {
+            /*
+             * Checks if typedef type is built-in type
+             */
+            if ((((YangTypeDef) node).getDataType().getDataType() != YangDataTypes.DERIVED)) {
+                return false;
+            }
+        } else if (getEntityToResolve() instanceof YangUses) {
+            /*
+             * Search if the grouping has any uses child, if so return false,
+             * else return true.
+             */
+            if (getUsesInGrouping(node) == null) {
+                return false;
+            }
+        } else {
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+        }
+        return true;
+    }
+
+    /**
+     * Return if there is any uses in grouping.
+     *
+     * @param node grouping/typedef node
+     * @return if there is any uses in grouping, otherwise return null
+     */
+    private YangUses getUsesInGrouping(YangNode node) {
+        YangNode curNode = ((YangGrouping) node).getChild();
+        while (curNode != null) {
+            if (curNode instanceof YangUses) {
+                break;
+            }
+            curNode = curNode.getNextSibling();
+        }
+        return (YangUses) curNode;
+    }
+
+    /**
+     * Resolve the complete stack.
+     *
+     * @throws DataModelException a violation of data model rules
+     */
+    private void resolveCompleteStack() throws DataModelException {
+        // For all entries in stack calls for the resolution in type/uses.
+        for (T entity:getPartialResolvedStack()) {
+            if (!(entity instanceof Resolvable)) {
+                throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+            }
+            ((Resolvable) entity).resolve();
+            // Set the resolution status in inside the type/uses.
+            ((Resolvable) entity).setResolvableStatus(ResolvableStatus.RESOLVED);
+        }
+        /*
+         * Set the resolution status in resolution info present in resolution
+         * list.
+         */
+        setIsResolved(true);
+    }
+
+    /**
+     * Add to partial resolved stack.
+     *
+     * @param node grouping/typedef node
+     * @throws DataModelException a violation of data model rules
+     */
+    private void addToPartialResolvedStack(YangNode node) throws DataModelException {
+        if (getPartialResolvedStack().peek() instanceof YangType) {
+            // Add to the stack only for YANG typedef.
+            getPartialResolvedStack().push((T) ((YangTypeDef) node).getDataType());
+        } else if (getPartialResolvedStack().peek() instanceof YangUses) {
+            getPartialResolvedStack().push((T) getUsesInGrouping(node));
+        } else {
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+        }
+    }
+
+    /**
+     * Check if prefix is associated with type/uses.
+     *
+     * @param node typedef/grouping node
+     * @return true if prefix is present, otherwise false
+     * @throws DataModelException a violation of data model rules
+     */
+    private boolean isExternalPrefixPresent(YangNode node) throws DataModelException {
+        if (getEntityToResolve() instanceof YangType) {
+            if (((YangTypeDef) node).getDataType().getPrefix() != null &&
+                    (!((YangTypeDef) node).getDataType().getPrefix().equals(resolutionInfoRootNodePrefix))) {
+                return true;
+            }
+        } else if (getEntityToResolve() instanceof YangUses) {
+            if (getUsesInGrouping(node).getPrefix() != null) {
+                return true;
+            }
+        } else {
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+        }
+        return false;
+    }
+
+    /**
+     * Returns prefix of imported module.
+     *
+     * @return prefix of imported module
+     */
+    public String getPrefix() {
+        return prefix;
+    }
+
+    /**
+     * Set prefix of imported module.
+     *
+     * @param prefix of imported module
+     */
+    public void setPrefix(String prefix) {
+        this.prefix = prefix;
+    }
+
+    /**
+     * Returns parsable entity which is to be resolved.
+     *
+     * @return parsable entity which is to be resolved
+     */
+    public T getEntityToResolve() {
+        return entityToResolve;
+    }
+
+    /**
+     * Set parsable entity to be resolved.
+     *
+     * @param entityToResolve YANG entity to be resolved
+     */
+    public void setEntityToResolve(T entityToResolve) {
+        this.entityToResolve = entityToResolve;
+    }
+
+    /**
+     * Returns parent YANG node holder for the entity to be resolved.
+     *
+     * @return parent YANG node holder
+     */
+    public YangNode getHolderOfEntityToResolve() {
+        return holderOfEntityToResolve;
+    }
+
+    /**
+     * Set parent YANG node holder for the entity to be resolved.
+     *
+     * @param holderOfEntityToResolve parent YANG node holder
+     */
+    public void setHolderOfEntityToResolve(YangNode holderOfEntityToResolve) {
+        this.holderOfEntityToResolve = holderOfEntityToResolve;
+    }
+
+    /**
+     * Returns error position.
+     *
+     * @return error position
+     */
+    public int getCharPosition() {
+        return charPosition;
+    }
+
+    /**
+     * Set error position.
+     *
+     * @param charPosition position of error
+     */
+    public void setCharPosition(int charPosition) {
+        this.charPosition = charPosition;
+    }
+
+    /**
+     * Returns error character position in line.
+     *
+     * @return error character position in line
+     */
+    public int getLineNumber() {
+        return lineNumber;
+    }
+
+    /**
+     * Set error character position in line.
+     *
+     * @param lineNumber error character position in line
+     */
+    public void setLineNumber(int lineNumber) {
+        this.lineNumber = lineNumber;
+    }
+
+    /**
+     * Returns status of resolution.
+     *
+     * @return resolution status
+     */
+    public boolean isResolved() {
+        return isResolved;
+    }
+
+    /**
+     * Set status of resolution.
+     *
+     * @param isResolved resolution status
+     */
+    public void setIsResolved(boolean isResolved) {
+        this.isResolved = isResolved;
+    }
+
+    /**
+     * Returns stack of YANG type with partially resolved YANG construct hierarchy.
+     *
+     * @return partial resolved YANG construct stack
+     */
+    public Stack<T> getPartialResolvedStack() {
+        return partialResolvedStack;
+    }
+
+    /**
+     * Set stack of YANG type with partially resolved YANG construct hierarchy.
+     *
+     * @param partialResolvedStack partial resolved YANG construct stack
+     */
+    public void setPartialResolvedStack(Stack<T> partialResolvedStack) {
+        this.partialResolvedStack = partialResolvedStack;
+    }
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
index 09e1a4d..f8d4606 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangSubModule.java
@@ -17,12 +17,12 @@
 
 import java.util.LinkedList;
 import java.util.List;
-
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.utils.YangConstructType;
 
 import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.detectCollidingChildUtil;
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.resolveLinkingForResolutionList;
 
 /*
  *  Reference RFC 6020.
@@ -75,7 +75,7 @@
  * Data model node to maintain information defined in YANG sub-module.
  */
 public class YangSubModule extends YangNode
-        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector {
+        implements YangLeavesHolder, YangDesc, YangReference, Parsable, CollisionDetector, HasResolutionInfo {
 
     /**
      * Name of sub module.
@@ -124,17 +124,17 @@
     private List<YangLeafList> listOfLeafList;
 
     /**
-     * organization owner of the sub-module.
+     * Organization owner of the sub-module.
      */
     private String organization;
 
     /**
-     * reference of the sub-module.
+     * Reference of the sub-module.
      */
     private String reference;
 
     /**
-     * revision info of the sub-module.
+     * Revision info of the sub-module.
      */
     private YangRevision revision;
 
@@ -144,10 +144,54 @@
     private byte version;
 
     /**
+     * Prefix of parent module.
+     */
+    private String prefix;
+    /*-
+     * Reference RFC 6020.
+     *
+     * Nested typedefs and groupings.
+     * Typedefs and groupings may appear nested under many YANG statements,
+     * allowing these to be lexically scoped by the hierarchy under which
+     * they appear.  This allows types and groupings to be defined near
+     * where they are used, rather than placing them at the top level of the
+     * hierarchy.  The close proximity increases readability.
+     *
+     * Scoping also allows types to be defined without concern for naming
+     * conflicts between types in different submodules.  Type names can be
+     * specified without adding leading strings designed to prevent name
+     * collisions within large modules.
+     *
+     * Finally, scoping allows the module author to keep types and groupings
+     * private to their module or submodule, preventing their reuse.  Since
+     * only top-level types and groupings (i.e., those appearing as
+     * sub-statements to a module or submodule statement) can be used outside
+     * the module or submodule, the developer has more control over what
+     * pieces of their module are presented to the outside world, supporting
+     * the need to hide internal information and maintaining a boundary
+     * between what is shared with the outside world and what is kept
+     * private.
+     *
+     * Scoped definitions MUST NOT shadow definitions at a higher scope.  A
+     * type or grouping cannot be defined if a higher level in the schema
+     * hierarchy has a definition with a matching identifier.
+     *
+     * A reference to an unprefixed type or grouping, or one which uses the
+     * prefix of the current module, is resolved by locating the closest
+     * matching "typedef" or "grouping" statement among the immediate
+     * sub-statements of each ancestor statement.
+     */
+    private List<YangResolutionInfo> unresolvedResolutionList;
+    /**
      * Create a sub module node.
      */
     public YangSubModule() {
         super(YangNodeType.SUB_MODULE_NODE);
+        unresolvedResolutionList = new LinkedList<YangResolutionInfo>();
+        importList = new LinkedList<YangImport>();
+        includeList = new LinkedList<YangInclude>();
+        listOfLeaf = new LinkedList<YangLeaf>();
+        listOfLeafList = new LinkedList<YangLeafList>();
     }
 
     /**
@@ -236,28 +280,17 @@
     }
 
     /**
-     * prevent setting the import list from outside.
-     *
-     * @param importList the import list to set
-     */
-    private void setImportList(List<YangImport> importList) {
-        this.importList = importList;
-    }
-
-    /**
      * Add the imported module information to the import list.
      *
      * @param importedModule module being imported
      */
-    public void addImportedInfo(YangImport importedModule) {
-
-        if (getImportList() == null) {
-            setImportList(new LinkedList<YangImport>());
-        }
-
+    public void addToImportList(YangImport importedModule) {
         getImportList().add(importedModule);
+    }
 
-        return;
+    @Override
+    public void setImportList(List<YangImport> importList) {
+        this.importList = importList;
     }
 
     /**
@@ -270,27 +303,35 @@
     }
 
     /**
-     * Set the list of included sub modules.
-     *
-     * @param includeList the included list to set
-     */
-    private void setIncludeList(List<YangInclude> includeList) {
-        this.includeList = includeList;
-    }
-
-    /**
      * Add the included sub module information to the include list.
      *
      * @param includeModule submodule being included
      */
-    public void addIncludedInfo(YangInclude includeModule) {
-
-        if (getIncludeList() == null) {
-            setIncludeList(new LinkedList<YangInclude>());
-        }
-
+    public void addToIncludeList(YangInclude includeModule) {
         getIncludeList().add(includeModule);
-        return;
+    }
+
+    @Override
+    public void setIncludeList(List<YangInclude> includeList) {
+        this.includeList = includeList;
+    }
+
+    @Override
+    public String getPrefix() {
+        return prefix;
+    }
+
+    @Override
+    public void setPrefix(String prefix) {
+        this.prefix = prefix;
+    }
+
+    @Override
+    public void resolveSelfFileLinking() throws DataModelException {
+        // Get the list to be resolved.
+        List<YangResolutionInfo> resolutionList = getUnresolvedResolutionList();
+        // Resolve linking for a resolution list.
+        resolveLinkingForResolutionList(resolutionList, this);
     }
 
     /**
@@ -304,25 +345,12 @@
     }
 
     /**
-     * Set the list of leaves.
-     *
-     * @param leafsList the list of leaf to set
-     */
-    private void setListOfLeaf(List<YangLeaf> leafsList) {
-        listOfLeaf = leafsList;
-    }
-
-    /**
      * Add a leaf.
      *
      * @param leaf the leaf to be added
      */
     @Override
     public void addLeaf(YangLeaf leaf) {
-        if (getListOfLeaf() == null) {
-            setListOfLeaf(new LinkedList<YangLeaf>());
-        }
-
         getListOfLeaf().add(leaf);
     }
 
@@ -337,25 +365,12 @@
     }
 
     /**
-     * Set the list of leaf-list.
-     *
-     * @param listOfLeafList the list of leaf-list to set
-     */
-    private void setListOfLeafList(List<YangLeafList> listOfLeafList) {
-        this.listOfLeafList = listOfLeafList;
-    }
-
-    /**
      * Add a leaf-list.
      *
      * @param leafList the leaf-list to be added
      */
     @Override
     public void addLeafList(YangLeafList leafList) {
-        if (getListOfLeafList() == null) {
-            setListOfLeafList(new LinkedList<YangLeafList>());
-        }
-
         getListOfLeafList().add(leafList);
     }
 
@@ -473,4 +488,19 @@
     public void detectSelfCollision(String identifierName, YangConstructType dataType) throws DataModelException {
         // Not required as module doesn't have any parent.
     }
+
+    @Override
+    public List<YangResolutionInfo> getUnresolvedResolutionList() {
+        return unresolvedResolutionList;
+    }
+
+    @Override
+    public void addToResolutionList(YangResolutionInfo resolutionInfo) {
+        this.unresolvedResolutionList.add(resolutionInfo);
+    }
+
+    @Override
+    public void setResolutionList(List<YangResolutionInfo> resolutionList) {
+        this.unresolvedResolutionList = resolutionList;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
index dd3e232..74c7a06 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangType.java
@@ -49,12 +49,12 @@
  *
  * @param <T> YANG data type info
  */
-public class YangType<T> implements Parsable {
+public class YangType<T> implements Parsable, Resolvable {
 
     /**
-     * YANG data type name.
+     * YANG node identifier.
      */
-    private String dataTypeName;
+    private YangNodeIdentifier nodeIdentifier;
 
     /**
      * Java package in which the Java type is defined.
@@ -74,9 +74,50 @@
     private T dataTypeExtendedInfo;
 
     /**
+     * Effective built-in type, requried in case type of typedef is again a
+     * derived type. This information is to be added during linking.
+     */
+    private YangDataTypes effectiveBuiltInType;
+
+    /**
+     * Effective pattern restriction, requried in case type of typedef is again
+     * a derived type. This information is to be added during linking.
+     */
+    private YangPatternRestriction effectivePatternRestriction;
+
+    /**
+     * Status of resolution. If completely resolved enum value is "RESOLVED",
+     * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
+     * is added to uses/type but it's not resolved value of enum should be
+     * "PARTIALLY_RESOLVED".
+     */
+    private ResolvableStatus resolvableStatus;
+
+    /**
      * Default constructor.
      */
     public YangType() {
+
+        nodeIdentifier = new YangNodeIdentifier();
+        resolvableStatus = ResolvableStatus.UNRESOLVED;
+    }
+
+    /**
+     * Returns prefix associated with data type name.
+     *
+     * @return prefix associated with data type name
+     */
+    public String getPrefix() {
+        return nodeIdentifier.getPrefix();
+    }
+
+    /**
+     * Set prefix associated with data type name.
+     *
+     * @param prefix prefix associated with data type name
+     */
+    public void setPrefix(String prefix) {
+        nodeIdentifier.setPrefix(prefix);
     }
 
     /**
@@ -85,7 +126,7 @@
      * @return the name of data type
      */
     public String getDataTypeName() {
-        return dataTypeName;
+        return nodeIdentifier.getName();
     }
 
     /**
@@ -94,7 +135,7 @@
      * @param typeName the name to set
      */
     public void setDataTypeName(String typeName) {
-        dataTypeName = typeName;
+        nodeIdentifier.setName(typeName);
     }
 
     /**
@@ -152,6 +193,60 @@
     }
 
     /**
+     * Returns node identifier.
+     *
+     * @return node identifier
+     */
+    public YangNodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    /**
+     * Set node identifier.
+     *
+     * @param nodeIdentifier the node identifier
+     */
+    public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
+        this.nodeIdentifier = nodeIdentifier;
+    }
+
+    /**
+     * Return effective built-in type.
+     *
+     * @return effective built-in type
+     */
+    public YangDataTypes getEffectiveBuiltInType() {
+        return effectiveBuiltInType;
+    }
+
+    /**
+     * Set effective built-in type.
+     *
+     * @param effectiveBuiltInType effective built-in type
+     */
+    public void setEffectiveBuiltInType(YangDataTypes effectiveBuiltInType) {
+        this.effectiveBuiltInType = effectiveBuiltInType;
+    }
+
+    /**
+     * Returns effective pattern restriction.
+     *
+     * @return effective pattern restriction
+     */
+    public YangPatternRestriction getEffectivePatternRestriction() {
+        return effectivePatternRestriction;
+    }
+
+    /**
+     * Set effective pattern restriction.
+     *
+     * @param effectivePatternRestriction effective pattern restriction
+     */
+    public void setEffectivePatternRestriction(YangPatternRestriction effectivePatternRestriction) {
+        this.effectivePatternRestriction = effectivePatternRestriction;
+    }
+
+    /**
      * Returns the type of the parsed data.
      *
      * @return returns TYPE_DATA
@@ -182,4 +277,19 @@
         // TODO auto-generated method stub, to be implemented by parser
 
     }
+
+    @Override
+    public ResolvableStatus getResolvableStatus() {
+        return resolvableStatus;
+    }
+
+    @Override
+    public void setResolvableStatus(ResolvableStatus resolvableStatus) {
+        this.resolvableStatus = resolvableStatus;
+    }
+
+    @Override
+    public void resolve() {
+        //TODO: implement the method.
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
index 736c300..a1f0fa1 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangTypeDef.java
@@ -75,9 +75,14 @@
     private YangStatusType status;
 
     /**
-     * Maintain the derived type information.
+     * Name of the typedef.
      */
-    private YangType<YangDerivedType> derivedType;
+    private String name;
+
+    /**
+     * Maintain the data type information.
+     */
+    private YangType<?> dataType;
 
     /**
      * Units of the data type.
@@ -92,7 +97,7 @@
     }
 
     /**
-     * Get the default value.
+     * Returns the default value.
      *
      * @return the default value
      */
@@ -110,7 +115,7 @@
     }
 
     /**
-     * Get the description.
+     * Returns the description.
      *
      * @return the description
      */
@@ -130,7 +135,7 @@
     }
 
     /**
-     * Get the textual reference.
+     * Returns the textual reference.
      *
      * @return the reference
      */
@@ -150,7 +155,7 @@
     }
 
     /**
-     * Get the status.
+     * Returns the status.
      *
      * @return the status
      */
@@ -170,25 +175,25 @@
     }
 
     /**
-     * Get the derived type.
+     * Returns the data type.
      *
-     * @return the derived type
+     * @return the data type
      */
-    public YangType<YangDerivedType> getDerivedType() {
-        return derivedType;
+    public YangType<?> getDataType() {
+        return dataType;
     }
 
     /**
-     * Set the derived type.
+     * Set the data type.
      *
-     * @param derivedType the derived type
+     * @param dataType the data type
      */
-    public void setDerivedType(YangType<YangDerivedType> derivedType) {
-        this.derivedType = derivedType;
+    public void setDataType(YangType<?> dataType) {
+        this.dataType = dataType;
     }
 
     /**
-     * Get the unit.
+     * Returns the unit.
      *
      * @return the units
      */
@@ -232,47 +237,17 @@
      */
     @Override
     public void validateDataOnExit() throws DataModelException {
-        YangType<YangDerivedType> type = getDerivedType();
-        if (type == null) {
-            throw new DataModelException("Typedef does not have type info.");
-        }
-        if (type.getDataType() != YangDataTypes.DERIVED
-                || type.getDataTypeName() == null) {
-            throw new DataModelException("Typedef type is not derived.");
-        }
-
-        YangDerivedType derivedTypeInfo = type.getDataTypeExtendedInfo();
-        if (derivedTypeInfo == null) {
-            throw new DataModelException("derrived type does not have derived info.");
-        }
-
-        YangType<?> baseType = derivedTypeInfo.getBaseType();
-        if (baseType == null) {
-            throw new DataModelException("Base type of a derived type is missing.");
-        }
-
-        if (derivedTypeInfo.getEffectiveYangBuiltInType() == null) {
-            /* resolve the effective type from the data tree. */
-            /*
-             * TODO: try to resolve the nested reference, if possible in the
-             * partial tree, otherwise we need to resolve finally when the
-             * complete module is created.
-             */
-            YangModule.addToResolveList(this);
-        }
+        // TODO auto-generated method stub, to be implemented by parser
     }
 
     /**
-     * Get the YANG name of the typedef.
+     * Returns the YANG name of the typedef.
      *
      * @return YANG name of the typedef
      */
     @Override
     public String getName() {
-        if (getDerivedType() != null) {
-            return getDerivedType().getDataTypeName();
-        }
-        return null;
+        return name;
     }
 
     /**
@@ -282,12 +257,6 @@
      */
     @Override
     public void setName(String name) {
-        if (getDerivedType() == null) {
-            throw new RuntimeException(
-                    "Derrived Type info needs to be set in parser when the typedef listner is processed");
-        }
-        getDerivedType().setDataTypeName(name);
-        getDerivedType().setDataType(YangDataTypes.DERIVED);
+        this.name = name;
     }
-
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
index d979bea..490b562 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/YangUses.java
@@ -52,12 +52,12 @@
  * Data model node to maintain information defined in YANG uses.
  *
  */
-public class YangUses extends YangNode implements YangCommonInfo, Parsable {
+public class YangUses extends YangNode implements YangCommonInfo, Parsable, Resolvable {
 
     /**
-     * Name of YANG uses.
+     * YANG node identifier.
      */
-    private String name;
+    private YangNodeIdentifier nodeIdentifier;
 
     /**
      * Referred group.
@@ -80,28 +80,20 @@
     private YangStatusType status;
 
     /**
+     * Status of resolution. If completely resolved enum value is "RESOLVED",
+     * if not enum value is "UNRESOLVED", in case reference of grouping/typedef
+     * is added to uses/type but it's not resolved value of enum should be
+     * "PARTIALLY_RESOLVED".
+     */
+    private ResolvableStatus resolvableStatus;
+
+    /**
      * Create an YANG uses node.
      */
     public YangUses() {
         super(YangNodeType.USES_NODE);
-    }
-
-    /**
-     * Returns the name.
-     *
-     * @return the name
-     */
-    public String getRefGroupingName() {
-        return name;
-    }
-
-    /**
-     * Set the name.
-     *
-     * @param refGroupingName the referred grouping name to set
-     */
-    public void setRefGroupingName(String refGroupingName) {
-        name = refGroupingName;
+        nodeIdentifier = new YangNodeIdentifier();
+        resolvableStatus = ResolvableStatus.UNRESOLVED;
     }
 
     /**
@@ -214,12 +206,62 @@
 
     @Override
     public String getName() {
-        return name;
+        return nodeIdentifier.getName();
     }
 
     @Override
     public void setName(String name) {
-        this.name = name;
+        nodeIdentifier.setName(name);
     }
 
+    /**
+     * Returns node identifier.
+     *
+     * @return node identifier
+     */
+    public YangNodeIdentifier getNodeIdentifier() {
+        return nodeIdentifier;
+    }
+
+    /**
+     * Set node identifier.
+     *
+     * @param nodeIdentifier the node identifier
+     */
+    public void setNodeIdentifier(YangNodeIdentifier nodeIdentifier) {
+        this.nodeIdentifier = nodeIdentifier;
+    }
+
+    /**
+     * Returns prefix associated with uses.
+     *
+     * @return prefix associated with uses
+     */
+    public String getPrefix() {
+        return nodeIdentifier.getPrefix();
+    }
+
+    /**
+     * Get prefix associated with uses.
+     *
+     * @param prefix prefix associated with uses
+     */
+    public void setPrefix(String prefix) {
+        nodeIdentifier.setPrefix(prefix);
+    }
+
+    @Override
+    public void resolve() {
+        //TODO: implement the method.
+    }
+
+    @Override
+    public ResolvableStatus getResolvableStatus() {
+        return resolvableStatus;
+    }
+
+    @Override
+    public void setResolvableStatus(ResolvableStatus resolvableStatus) {
+        this.resolvableStatus = resolvableStatus;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/exceptions/DataModelException.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/exceptions/DataModelException.java
index 8683928..50e2c34 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/exceptions/DataModelException.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/exceptions/DataModelException.java
@@ -21,6 +21,8 @@
 public class DataModelException extends Exception {
 
     private static final long serialVersionUID = 201601270658L;
+    private int lineNumber;
+    private int charPositionInLine;
 
     /**
      * Constructor to create a data model exception with message.
@@ -49,4 +51,40 @@
     public DataModelException(final Throwable cause) {
         super(cause);
     }
+
+    /**
+     * Returns line number of the exception.
+     *
+     * @return line number of the exception
+     */
+    public int getLineNumber() {
+        return this.lineNumber;
+    }
+
+    /**
+     * Returns position of the exception.
+     *
+     * @return position of the exception
+     */
+    public int getCharPositionInLine() {
+        return this.charPositionInLine;
+    }
+
+    /**
+     * Sets line number of YANG file.
+     *
+     * @param line line number of YANG file
+     */
+    public void setLine(int line) {
+        this.lineNumber = line;
+    }
+
+    /**
+     * Sets position of exception.
+     *
+     * @param charPosition position of exception
+     */
+    public void setCharPosition(int charPosition) {
+        this.charPositionInLine = charPosition;
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
index e736631..c4609dc 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/datamodel/utils/DataModelUtils.java
@@ -16,11 +16,14 @@
 
 package org.onosproject.yangutils.datamodel.utils;
 
+import java.util.List;
 import org.onosproject.yangutils.datamodel.CollisionDetector;
+import org.onosproject.yangutils.datamodel.HasResolutionInfo;
 import org.onosproject.yangutils.datamodel.YangLeaf;
 import org.onosproject.yangutils.datamodel.YangLeafList;
 import org.onosproject.yangutils.datamodel.YangLeavesHolder;
 import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangResolutionInfo;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.utils.YangConstructType;
 
@@ -39,27 +42,23 @@
      * Detects the colliding identifier name in a given YANG node and its child.
      *
      * @param identifierName name for which collision detection is to be
-     *            checked.
-     * @param dataType type of YANG node asking for detecting collision.
-     * @param node instance of calling node.
-     * @throws DataModelException a violation of data model rules.
+     *            checked
+     * @param dataType type of YANG node asking for detecting collision
+     * @param node instance of calling node
+     * @throws DataModelException a violation of data model rules
      */
     public static void detectCollidingChildUtil(String identifierName, YangConstructType dataType, YangNode node)
             throws DataModelException {
-        if (((YangLeavesHolder) node).getListOfLeaf() != null) {
-            for (YangLeaf leaf : ((YangLeavesHolder) node).getListOfLeaf()) {
-                if (leaf.getLeafName().equals(identifierName)) {
-                    throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \""
-                            + leaf.getLeafName() + "\"");
-                }
+        if (dataType == YangConstructType.LEAF_DATA) {
+            YangLeavesHolder leavesHolder = (YangLeavesHolder) node;
+            if (leavesHolder.getListOfLeaf() != null) {
+                detectCollidingLeaf(leavesHolder, identifierName);
             }
         }
-        if (((YangLeavesHolder) node).getListOfLeafList() != null) {
-            for (YangLeafList leafList : ((YangLeavesHolder) node).getListOfLeafList()) {
-                if (leafList.getLeafName().equals(identifierName)) {
-                    throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " +
-                            "list \"" + leafList.getLeafName() + "\"");
-                }
+        if (dataType == YangConstructType.LEAF_LIST_DATA) {
+            if (((YangLeavesHolder) node).getListOfLeafList() != null) {
+                YangLeavesHolder leavesHolder = (YangLeavesHolder) node;
+                detectCollidingLeafList(leavesHolder, identifierName);
             }
         }
         node = node.getChild();
@@ -70,4 +69,78 @@
             node = node.getNextSibling();
         }
     }
+
+    /**
+     * Detects the colliding identifier name in a given leaf node.
+     *
+     * @param leavesHolder leaves node against which collision to be checked
+     * @param identifierName name for which collision detection is to be
+     *            checked
+     * @throws DataModelException a violation of data model rules
+     */
+    private static void detectCollidingLeaf(YangLeavesHolder leavesHolder, String identifierName) throws
+            DataModelException {
+        for (YangLeaf leaf : leavesHolder.getListOfLeaf()) {
+            if (leaf.getLeafName().equals(identifierName)) {
+                throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf \""
+                        + leaf.getLeafName() + "\"");
+            }
+        }
+    }
+
+    /**
+     * Detects the colliding identifier name in a given leaf-list node.
+     *
+     * @param leavesHolder leaves node against which collision to be checked
+     * @param identifierName name for which collision detection is to be
+     *            checked
+     * @throws DataModelException a violation of data model rules
+     */
+    private static void detectCollidingLeafList(YangLeavesHolder leavesHolder, String identifierName) throws
+            DataModelException {
+        for (YangLeafList leafList : leavesHolder.getListOfLeafList()) {
+            if (leafList.getLeafName().equals(identifierName)) {
+                throw new DataModelException("YANG file error: Duplicate input identifier detected, same as leaf " +
+                        "list \"" + leafList.getLeafName() + "\"");
+            }
+        }
+    }
+
+    /**
+     * Add a resolution information.
+     *
+     * @param resolutionInfo information about the YANG construct which has to
+     *                       be resolved
+     * @throws DataModelException a violation of data model rules
+     */
+    public static void addResolutionInfo(YangResolutionInfo resolutionInfo) throws DataModelException {
+        /* get the module node to add maintain the list of nested reference */
+        YangNode curNode = resolutionInfo.getHolderOfEntityToResolve();
+        while (!(curNode instanceof HasResolutionInfo)) {
+            curNode = curNode.getParent();
+            if (curNode == null) {
+                throw new DataModelException("Internal datamodel error: Datamodel tree is not correct");
+            }
+        }
+        HasResolutionInfo resolutionNode = (HasResolutionInfo) curNode;
+        resolutionNode.addToResolutionList(resolutionInfo);
+    }
+
+    /**
+     * Resolve linking for a resolution list.
+     *
+     * @param resolutionList resolution list for which linking to be done
+     * @param resolutionInfoNode module/sub-module node
+     * @throws DataModelException a violation of data model rules
+     */
+    public static void resolveLinkingForResolutionList(List<YangResolutionInfo> resolutionList,
+                                                       HasResolutionInfo resolutionInfoNode)
+            throws DataModelException {
+        for (YangResolutionInfo resolutionInfo : resolutionList) {
+            if (resolutionInfo.getPrefix() == null ||
+                    resolutionInfo.getPrefix().equals(resolutionInfoNode.getPrefix())) {
+                resolutionInfo.resolveLinkingForResolutionInfo(resolutionInfoNode.getPrefix());
+            }
+        }
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/YangLinker.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/YangLinker.java
new file mode 100644
index 0000000..df817ff
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/YangLinker.java
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2016 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.linker;
+
+import java.util.Map;
+import org.onosproject.yangutils.datamodel.HasResolutionInfo;
+
+/**
+ * Abstraction of entity which provides linking service of YANG files.
+ */
+public interface YangLinker {
+
+    /**
+     * Resolve the import and include dependencies for a given resolution
+     * information.
+     *
+     * @param fileMapEntry map entry for which resolution is to be done
+     * @param yangFilesMap map of dependent file and resolution information*/
+    void resolveDependencies(Map.Entry<String, HasResolutionInfo> fileMapEntry, Map<String,
+            HasResolutionInfo> yangFilesMap);
+}
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/impl/package-info.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/impl/package-info.java
new file mode 100644
index 0000000..3b87848
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * Provide inter file and inter jar linking implementation.
+ */
+package org.onosproject.yangutils.linker.impl;
\ No newline at end of file
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/package-info.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/package-info.java
new file mode 100644
index 0000000..e0195c3
--- /dev/null
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/linker/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * Provide inter jar and inter file linking abstract interface.
+ */
+package org.onosproject.yangutils.linker;
\ No newline at end of file
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
index 92b1ee9..12c292a 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/BelongsToListener.java
@@ -23,13 +23,13 @@
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
 
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 import static org.onosproject.yangutils.utils.YangConstructType.BELONGS_TO_DATA;
 
@@ -119,6 +119,7 @@
             case SUB_MODULE_DATA: {
                 YangSubModule subModule = (YangSubModule) tmpNode;
                 subModule.setBelongsTo((YangBelongsTo) tmpBelongstoNode);
+                subModule.setPrefix(subModule.getBelongsTo().getPrefix());
                 break;
             }
             default:
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
index f34bd30..63dfbc7 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ImportListener.java
@@ -113,12 +113,12 @@
             switch (tmpNode.getYangConstructType()) {
             case MODULE_DATA: {
                 YangModule module = (YangModule) tmpNode;
-                module.addImportedInfo((YangImport) tmpImportNode);
+                module.addToImportList((YangImport) tmpImportNode);
                 break;
             }
             case SUB_MODULE_DATA: {
                 YangSubModule subModule = (YangSubModule) tmpNode;
-                subModule.addImportedInfo((YangImport) tmpImportNode);
+                subModule.addToImportList((YangImport) tmpImportNode);
                 break;
             }
             default:
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
index b9325da..9cd6a26 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListener.java
@@ -24,13 +24,13 @@
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
 
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 import static org.onosproject.yangutils.utils.YangConstructType.INCLUDE_DATA;
 
@@ -112,12 +112,12 @@
             switch (tmpNode.getYangConstructType()) {
             case MODULE_DATA: {
                 YangModule module = (YangModule) tmpNode;
-                module.addIncludedInfo((YangInclude) tmpIncludeNode);
+                module.addToIncludeList((YangInclude) tmpIncludeNode);
                 break;
             }
             case SUB_MODULE_DATA: {
                 YangSubModule subModule = (YangSubModule) tmpNode;
-                subModule.addIncludedInfo((YangInclude) tmpIncludeNode);
+                subModule.addToIncludeList((YangInclude) tmpIncludeNode);
                 break;
             }
             default:
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
index ef302be..51f8364 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
@@ -16,8 +16,10 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import org.onosproject.yangutils.datamodel.HasResolutionInfo;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangRevision;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -113,5 +115,13 @@
             throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MODULE_DATA,
                     ctx.identifier().getText(), EXIT));
         }
+        try {
+            ((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking();
+        } catch (DataModelException e) {
+            ParserException parserException = new ParserException(e.getMessage());
+            parserException.setLine(e.getLineNumber());
+            parserException.setCharPosition(e.getCharPositionInLine());
+            throw parserException;
+        }
     }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
index eb16253..225aff5 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
@@ -16,8 +16,10 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import org.onosproject.yangutils.datamodel.HasResolutionInfo;
 import org.onosproject.yangutils.datamodel.YangRevision;
 import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -118,5 +120,13 @@
             throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, SUB_MODULE_DATA,
                     ctx.identifier().getText(), EXIT));
         }
+        try {
+            ((HasResolutionInfo) listener.getParsedDataStack().peek()).resolveSelfFileLinking();
+        } catch (DataModelException e) {
+            ParserException parserException = new ParserException(e.getMessage());
+            parserException.setLine(e.getLineNumber());
+            parserException.setCharPosition(e.getCharPositionInLine());
+            throw parserException;
+        }
     }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java
index 3ca81fb..74e1f0d 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeDefListener.java
@@ -17,18 +17,15 @@
 package org.onosproject.yangutils.parser.impl.listeners;
 
 import org.onosproject.yangutils.datamodel.YangContainer;
-import org.onosproject.yangutils.datamodel.YangDataTypes;
-import org.onosproject.yangutils.datamodel.YangDerivedType;
+import org.onosproject.yangutils.datamodel.YangInput;
 import org.onosproject.yangutils.datamodel.YangList;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangSubModule;
-import org.onosproject.yangutils.datamodel.YangType;
-import org.onosproject.yangutils.datamodel.YangTypeDef;
-import org.onosproject.yangutils.datamodel.YangInput;
-import org.onosproject.yangutils.datamodel.YangOutput;
 import org.onosproject.yangutils.datamodel.YangNotification;
+import org.onosproject.yangutils.datamodel.YangOutput;
 import org.onosproject.yangutils.datamodel.YangRpc;
+import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
@@ -123,12 +120,8 @@
          * Create a derived type information, the base type must be set in type
          * listener.
          */
-        YangType<YangDerivedType> derivedType = new YangType<YangDerivedType>();
-        derivedType.setDataType(YangDataTypes.DERIVED);
-        derivedType.setDataTypeName(identifier);
-
         YangTypeDef typeDefNode = getYangTypeDefNode(JAVA_GENERATION);
-        typeDefNode.setDerivedType(derivedType);
+        typeDefNode.setName(identifier);
 
         Parsable curData = listener.getParsedDataStack().peek();
 
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
index b000242..6f2f795 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
@@ -16,10 +16,14 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import org.onosproject.yangutils.datamodel.ResolutionType;
 import org.onosproject.yangutils.datamodel.YangDataTypes;
-import org.onosproject.yangutils.datamodel.YangDerivedType;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
 import org.onosproject.yangutils.datamodel.YangLeaf;
 import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
+import org.onosproject.yangutils.datamodel.YangResolutionInfo;
 import org.onosproject.yangutils.datamodel.YangType;
 import org.onosproject.yangutils.datamodel.YangTypeDef;
 import org.onosproject.yangutils.datamodel.YangUnion;
@@ -28,13 +32,18 @@
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+import org.onosproject.yangutils.utils.YangConstructType;
 
+import static org.onosproject.yangutils.datamodel.utils.DataModelUtils.addResolutionInfo;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.ENTRY;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation.EXIT;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructExtendedListenerErrorMessage;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction.constructListenerErrorMessage;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.INVALID_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_CURRENT_HOLDER;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.MISSING_HOLDER;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType.UNHANDLED_PARSED_DATA;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidNodeIdentifier;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
 
@@ -77,12 +86,19 @@
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), ENTRY);
 
-        YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText());
-        YangType<?> type = new YangType();
+        // Validate node identifier.
+        YangNodeIdentifier nodeIdentifier = getValidNodeIdentifier(ctx.string().getText(), YangConstructType.TYPE_DATA,
+                ctx);
 
-        type.setDataTypeName(ctx.string().getText());
+        // Obtain the YANG data type.
+        YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText());
+
+        // Create YANG type object and fill the values.
+        YangType<?> type = new YangType();
+        type.setNodeIdentifier(nodeIdentifier);
         type.setDataType(yangDataTypes);
 
+        // Push the type to the stack.
         listener.getParsedDataStack().push(type);
     }
 
@@ -99,24 +115,91 @@
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_CURRENT_HOLDER, TYPE_DATA, ctx.string().getText(), EXIT);
 
-        Parsable type = listener.getParsedDataStack().pop();
-        if (!(type instanceof YangType)) {
+        Parsable parsableType = listener.getParsedDataStack().pop();
+        if (!(parsableType instanceof YangType)) {
             throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
                     ctx.string().getText(), EXIT));
         }
 
+        YangType<?> type = (YangType<?>) parsableType;
+
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), EXIT);
 
+        YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText());
+
+        int errorLine = ctx.getStart().getLine();
+        int errorPosition = ctx.getStart().getCharPositionInLine();
+
         Parsable tmpData = listener.getParsedDataStack().peek();
         switch (tmpData.getYangConstructType()) {
             case LEAF_DATA:
                 YangLeaf leaf = (YangLeaf) tmpData;
                 leaf.setDataType((YangType<?>) type);
+
+                /*
+                 * If data type is derived, resolution information to be added
+                 * in resolution list.
+                 */
+                if (yangDataTypes == YangDataTypes.DERIVED) {
+                    // Parent YANG node of leaf to be added in resolution information.
+                    Parsable leafData = listener.getParsedDataStack().pop();
+                    Parsable parentNodeOfLeaf = listener.getParsedDataStack().peek();
+                    listener.getParsedDataStack().push(leafData);
+
+                    // Verify parent node of leaf
+                    if (!(parentNodeOfLeaf instanceof YangNode)) {
+                        throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
+                                ctx.string().getText(), EXIT));
+                    }
+
+                    // Get the prefix information
+                    String prefix = ((YangType<?>) type).getPrefix();
+
+                    // Create empty derived info and attach it to type extended info.
+                    YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
+                    ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
+
+                    // Add resolution information to the list
+                    YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type,
+                            ResolutionType.TYPEDEF_RESOLUTION, (YangNode) parentNodeOfLeaf, prefix, errorLine,
+                            errorPosition);
+                    addToResolutionList(resolutionInfo, ctx);
+                }
                 break;
             case LEAF_LIST_DATA:
                 YangLeafList leafList = (YangLeafList) tmpData;
                 leafList.setDataType((YangType<?>) type);
+
+                /*
+                 * If data type is derived, resolution information to be added
+                 * in resolution list.
+                 */
+                if (yangDataTypes == YangDataTypes.DERIVED) {
+                    // Parent YANG node of leaf to be added in resolution information.
+                    Parsable leafListData = listener.getParsedDataStack().pop();
+                    Parsable parentNodeOfLeafList = listener.getParsedDataStack().peek();
+                    listener.getParsedDataStack().push(leafListData);
+
+                    // Verify parent node of leaf
+                    if (!(parentNodeOfLeafList instanceof YangNode)) {
+                        throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
+                                ctx.string().getText(), EXIT));
+                    }
+
+                    // Get the prefix information
+                    String prefix = ((YangType<?>) type).getPrefix();
+
+                    // Create empty derived info and attach it to type extended info.
+                    YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
+                    ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
+
+                    // Add resolution information to the list
+                    YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type,
+                            ResolutionType.TYPEDEF_RESOLUTION, (YangNode) parentNodeOfLeafList, prefix, errorLine,
+                            errorPosition);
+                    addToResolutionList(resolutionInfo, ctx);
+                }
                 break;
             case UNION_DATA:
                 YangUnion unionNode = (YangUnion) tmpData;
@@ -130,34 +213,50 @@
                 }
                 break;
             case TYPEDEF_DATA:
-
                 /* Prepare the base type info and set in derived type */
                 YangTypeDef typeDef = (YangTypeDef) tmpData;
-                YangType<YangDerivedType> derivedType = typeDef.getDerivedType();
-                if (derivedType == null) {
-                    //TODO: set the error info correctly, to depict missing info
-                    throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
-                            ctx.string().getText(), ENTRY));
-                }
+                typeDef.setDataType((YangType<?>) type);
 
-                YangDerivedType derivedTypeInfo = new YangDerivedType();
-                if (((YangType<?>) type).getDataType() != YangDataTypes.DERIVED) {
-                    derivedTypeInfo.setEffectiveYangBuiltInType(((YangType<?>) type).getDataType());
-                } else {
-                    /*
-                     * It will be resolved in the validate data model at exit.
-                     * Nothing needs to be done.
-                     */
-                }
-                derivedTypeInfo.setBaseType((YangType<?>) type);
-                derivedType.setDataTypeExtendedInfo(derivedTypeInfo);
+                /*
+                 * If data type is derived, resolution information to be added
+                 * in resolution list.
+                 */
+                if (yangDataTypes == YangDataTypes.DERIVED) {
 
+                    // Get the prefix information
+                    String prefix = ((YangType<?>) type).getPrefix();
+
+                    // Create empty derived info and attach it to type extended info.
+                    YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
+                    ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
+
+                    // Add resolution information to the list
+                    YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type,
+                            ResolutionType.TYPEDEF_RESOLUTION, (YangNode) typeDef, prefix, errorLine, errorPosition);
+                    addToResolutionList(resolutionInfo, ctx);
+                }
                 break;
-            //TODO: union, deviate replacement statement.case TYPEDEF_DATA: //TODO
+            //TODO: deviate replacement statement.case TYPEDEF_DATA: //TODO
 
             default:
                 throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, TYPE_DATA,
                         ctx.string().getText(), EXIT));
         }
     }
+
+    /**
+     * Add to resolution list.
+     *
+     * @param resolutionInfo resolution information.
+     * @param ctx context object of the grammar rule
+     */
+    private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo,
+                                            GeneratedYangParser.TypeStatementContext ctx) {
+        try {
+            addResolutionInfo(resolutionInfo);
+        } catch (DataModelException e) {
+            throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                    TYPE_DATA, ctx.string().getText(), EXIT, e.getMessage()));
+        }
+    }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
index 4ceb55a..6396c9c 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/translator/tojava/TempJavaCodeFragmentFiles.java
@@ -1102,7 +1102,7 @@
     public void addTypeDefAttributeToTempFiles(YangNode curNode) throws IOException {
 
         JavaAttributeInfo javaAttributeInfo = getAttributeInfoOfTypeDef(curNode,
-                ((YangTypeDef) curNode).getDerivedType().getDataTypeExtendedInfo().getBaseType(),
+                ((YangTypeDef) curNode).getDataType(),
                 ((YangTypeDef) curNode).getName(), false);
         addJavaSnippetInfoToApplicableTempFiles(javaAttributeInfo);
     }
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
new file mode 100644
index 0000000..67fcf07
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/linker/IntraFileTypeLinkingTest.java
@@ -0,0 +1,420 @@
+/*
+ * Copyright 2016 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.linker;
+
+import java.io.IOException;
+import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.ResolvableStatus;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing "type" intra file linking.
+ */
+public class IntraFileTypeLinkingTest {
+
+    private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+    /**
+     * Checks self resolution when typedef and leaf using type are siblings.
+     */
+    @Test
+    public void processSelfResolutionWhenTypeAndTypedefAtRootLevel() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.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();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) node.getChild()));
+
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when typedef and leaf using type are at different
+     * level where typedef is at the root.
+     */
+    @Test
+    public void processSelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.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"));
+
+        YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+        YangList yangList = (YangList) yangContainer.getChild();
+
+        ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) node.getChild()));
+
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when typedef and leaf using type are at different
+     * level where typedef is at the root and defined after parent holder
+     * of type.
+     */
+    @Test
+    public void processSelfFileLinkingTypedefAtRootIsAfterContainerHavingType() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.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"));
+
+        YangContainer yangContainer = (YangContainer) node.getChild();
+
+        YangList yangList = (YangList) yangContainer.getChild();
+
+        ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) node.getChild().getNextSibling()));
+
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when typedef and leaf using type are at different
+     * level where typedef is at the level of root+1 and defined after parent
+     * holder of type.
+     */
+    @Test
+    public void processSelfFileLinkingTypedefAtMiddleLevelAfterParentHolder() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.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"));
+
+        YangContainer yangContainer = (YangContainer) node.getChild();
+
+        YangList yangList = (YangList) yangContainer.getChild();
+
+        ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when typedef hierarchical references are present.
+     */
+    @Test
+    public void processSelfFileLinkingWithTypdefHierarchicalReference() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.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"));
+
+        YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+        YangList yangList = (YangList) yangContainer.getChild();
+
+        ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangList.getChild()));
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+
+        YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+        assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+        assertThat((typeDef1.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+
+        YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+        assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) node.getChild()));
+        assertThat((typeDef2.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when typedef hierarchical references are present
+     * with last type is unresolved.
+     */
+    @Test
+    public void processSelfFileLinkingWithTypdefHierarchicalRefUnresolved() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.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"));
+
+        YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+        YangList yangList = (YangList) yangContainer.getChild();
+
+        ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangList.getChild()));
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.PARTIALLY_RESOLVED));
+
+        YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+        assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+        assertThat((typeDef1.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.PARTIALLY_RESOLVED));
+
+        YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+        assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) node.getChild()));
+        assertThat((typeDef2.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.PARTIALLY_RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when type uses prefix of self module.
+     */
+    @Test
+    public void processSelfFileLinkingWithTypeWithSelfModulePrefix() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.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"));
+
+        YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+        YangList yangList = (YangList) yangContainer.getChild();
+
+        ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangList.getChild()));
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+
+        YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+        assertThat(((YangDerivedInfo<?>) typeDef1.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangContainer.getChild().getNextSibling()));
+        assertThat((typeDef1.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+
+        YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+        assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) node.getChild()));
+        assertThat((typeDef2.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Checks self resolution when some type uses prefix of self module
+     * some uses external prefix.
+     */
+    @Test
+    public void processSelfFileLinkingWithTypeWithSelfAndExternalPrefixMix() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.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"));
+
+        YangContainer yangContainer = (YangContainer) node.getChild().getNextSibling();
+
+        YangList yangList = (YangList) yangContainer.getChild();
+
+        ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+        YangLeaf leafInfo = leafIterator.next();
+
+        assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("FirstClass"));
+        assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+
+        assertThat(((YangDerivedInfo<?>) leafInfo.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) yangList.getChild()));
+        assertThat((leafInfo.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.PARTIALLY_RESOLVED));
+
+        YangTypeDef typeDef1 = (YangTypeDef) yangList.getChild();
+
+        YangTypeDef typeDef2 = (YangTypeDef) yangContainer.getChild().getNextSibling();
+
+        assertThat(((YangDerivedInfo<?>) typeDef2.getDataType().getDataTypeExtendedInfo()).getReferredTypeDef(),
+                is((YangTypeDef) node.getChild()));
+        assertThat((typeDef2.getDataType().getResolvableStatus()),
+                is(ResolvableStatus.RESOLVED));
+    }
+
+    /**
+     * Check self resolution when type referred typedef is not available in
+     * file.
+     */
+    @Test(expected = ParserException.class)
+    public void processSelfResolutionWhenTypeReferredTypedefNotDefined() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang");
+    }
+
+    /**
+     * Checks self resolution when typedef and leaf using type are at different
+     * level where typedef is is not an ancestor of type.
+     */
+    @Test(expected = ParserException.class)
+    public void processSelfFileLinkingTypedefNotFound() throws IOException, ParserException {
+
+        YangNode node = manager.getDataModel("src/test/resources/SelfFileLinkingTypedefNotFound.yang");
+    }
+
+    /**
+     * Checks hierarchical self resolution with self resolution failure scenario.
+     */
+    @Test(expected = ParserException.class)
+    public void processSelfFileLinkingWithHierarchicalTypeFailureScenario() throws IOException, ParserException {
+
+        YangNode node =
+                manager.getDataModel("src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang");
+    }
+}
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
index 7e693d5..cd94ec6 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.util.ListIterator;
-
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -170,7 +169,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -206,7 +205,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
index b34209e..60132618 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
@@ -193,7 +193,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java
index f3042bb..83bc719 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.util.ListIterator;
-
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -178,7 +177,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -215,7 +214,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
index b150f81..6e1d651 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.util.ListIterator;
-
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -68,7 +67,7 @@
         YangLeafList leafListInfo = leafListIterator.next();
 
         assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafListInfo.getUnits(), is("\"seconds\""));
         assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -163,7 +162,7 @@
         YangLeafList leafListInfo = leafListIterator.next();
 
         assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafListInfo.getUnits(), is("\"seconds\""));
         assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -200,7 +199,7 @@
         YangLeafList leafListInfo = leafListIterator.next();
 
         assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafListInfo.getUnits(), is("\"seconds\""));
         assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
index da9bb35..a5863d6 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
@@ -68,7 +68,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -162,7 +162,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -225,7 +225,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
index 86d1a0b..bee66aa 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
@@ -162,7 +162,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NotificationListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NotificationListenerTest.java
index b6a57d9..5a86d33 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NotificationListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NotificationListenerTest.java
@@ -16,20 +16,18 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
-import org.junit.Test;
-import org.onosproject.yangutils.datamodel.YangNode;
-import org.onosproject.yangutils.datamodel.YangModule;
-import org.onosproject.yangutils.datamodel.YangNotification;
-import org.onosproject.yangutils.datamodel.YangStatusType;
-import org.onosproject.yangutils.datamodel.YangNodeType;
-import org.onosproject.yangutils.datamodel.YangTypeDef;
-import org.onosproject.yangutils.datamodel.YangLeaf;
-import org.onosproject.yangutils.datamodel.YangDataTypes;
-import org.onosproject.yangutils.parser.exceptions.ParserException;
-import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
-
 import java.io.IOException;
 import java.util.ListIterator;
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangNotification;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangTypeDef;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
 
 import static org.hamcrest.core.Is.is;
 import static org.junit.Assert.assertThat;
@@ -63,8 +61,6 @@
         YangTypeDef typeDef = (YangTypeDef) yangNotification.getChild();
         assertThat(typeDef.getName(), is("my-type"));
         assertThat(typeDef.getStatus(), is(YangStatusType.DEPRECATED));
-        assertThat(typeDef.getDerivedType().getDataTypeExtendedInfo()
-                .getBaseType().getDataType(), is(YangDataTypes.INT32));
 
         ListIterator<YangLeaf> leafIterator = yangNotification.getListOfLeaf().listIterator();
         YangLeaf leafInfo = leafIterator.next();
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java
index c398569..a0bcd1c 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.util.ListIterator;
-
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -177,7 +176,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -214,7 +213,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
index 984b0f2..ed76c6d 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.util.ListIterator;
-
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -187,7 +186,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
@@ -224,7 +223,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
index a1146aa..d263bb0 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
@@ -2,7 +2,6 @@
 
 import java.io.IOException;
 import java.util.ListIterator;
-
 import org.junit.Test;
 import org.onosproject.yangutils.datamodel.YangDataTypes;
 import org.onosproject.yangutils.datamodel.YangLeaf;
@@ -45,7 +44,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"hello\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
     }
 
@@ -71,7 +70,7 @@
         YangLeaf leafInfo = leafIterator.next();
 
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
     }
 
@@ -97,7 +96,7 @@
         YangLeafList leafListInfo = leafListIterator.next();
 
         assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
     }
 }
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
index dc5ff59..516848c 100644
--- a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 import java.util.ListIterator;
-
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -117,7 +116,7 @@
 
         // Check whether leaf properties is set correctly.
         assertThat(leafInfo.getLeafName(), is("invalid-interval"));
-        assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+        assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
         assertThat(leafInfo.getUnits(), is("\"seconds\""));
         assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
         assertThat(leafInfo.isConfig(), is(true));
diff --git a/utils/yangutils/src/test/resources/DerivedTypeStatement.yang b/utils/yangutils/src/test/resources/DerivedTypeStatement.yang
index c678822..952b7d4 100644
--- a/utils/yangutils/src/test/resources/DerivedTypeStatement.yang
+++ b/utils/yangutils/src/test/resources/DerivedTypeStatement.yang
@@ -3,6 +3,6 @@
     namespace http://huawei.com;
     prefix Ant;
     leaf invalid-interval {
-        type "hello";
+        type P:hello;
     }
-}
\ No newline at end of file
+}
diff --git a/utils/yangutils/src/test/resources/GroupingAttributes.yang b/utils/yangutils/src/test/resources/GroupingAttributes.yang
index 7eb3880..977adc5 100644
--- a/utils/yangutils/src/test/resources/GroupingAttributes.yang
+++ b/utils/yangutils/src/test/resources/GroupingAttributes.yang
@@ -5,17 +5,17 @@
     list valid {
         key address;
         leaf address {
-            type ip;
+            type P:ip;
         }
         grouping endpoint {
             description "grouping under test";
             status current;
             reference "RFC 6020";
             leaf address {
-                type ip-address;
+                type P:ip-address;
             }
             leaf port {
-                type port-number;
+                type P:port-number;
             }
         }
     }
diff --git a/utils/yangutils/src/test/resources/GroupingInContainer.yang b/utils/yangutils/src/test/resources/GroupingInContainer.yang
index be9e7e8..7c51913 100644
--- a/utils/yangutils/src/test/resources/GroupingInContainer.yang
+++ b/utils/yangutils/src/test/resources/GroupingInContainer.yang
@@ -5,10 +5,10 @@
     container valid {
         grouping endpoint {
             leaf address {
-                type ip-address;
+                type P:ip-address;
             }
             leaf port {
-                type port-number;
+                type P:port-number;
             }
         }
     }
diff --git a/utils/yangutils/src/test/resources/GroupingInList.yang b/utils/yangutils/src/test/resources/GroupingInList.yang
index 2cdf7d1..a8fad09 100644
--- a/utils/yangutils/src/test/resources/GroupingInList.yang
+++ b/utils/yangutils/src/test/resources/GroupingInList.yang
@@ -5,14 +5,14 @@
     list valid {
         key address;
         leaf address {
-            type ip;
+            type P:ip;
         }
         grouping endpoint {
             leaf address {
-                type ip-address;
+                type P:ip-address;
             }
             leaf port {
-                type port-number;
+                type P:port-number;
             }
         }
     }
diff --git a/utils/yangutils/src/test/resources/GroupingInModule.yang b/utils/yangutils/src/test/resources/GroupingInModule.yang
index d0a31c1..7d513a4 100644
--- a/utils/yangutils/src/test/resources/GroupingInModule.yang
+++ b/utils/yangutils/src/test/resources/GroupingInModule.yang
@@ -4,10 +4,10 @@
     prefix Ant;
     grouping endpoint {
         leaf address {
-            type ip-address;
+            type P:ip-address;
         }
         leaf port {
-            type port-number;
+            type P:port-number;
         }
     }
 }
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
new file mode 100644
index 0000000..c372bfa
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtMiddleLevelAfterParentHolder.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type hello;
+            }
+        }
+        typedef hello {
+            type String;
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
new file mode 100644
index 0000000..052cb7e
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtRootIsAfterContainerHavingType.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type hello;
+            }
+        }
+    }
+    typedef hello {
+        type String;
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
new file mode 100644
index 0000000..2b4a1e8
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefAtRootTypeTwoLevelInHierarchy.yang
@@ -0,0 +1,16 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef hello {
+        type String;
+    }
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type hello;
+            }
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingTypedefNotFound.yang b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefNotFound.yang
new file mode 100644
index 0000000..9248598
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingTypedefNotFound.yang
@@ -0,0 +1,18 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type hello;
+            }
+        }
+    }
+    container isis {
+        typedef hello {
+            type String;
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang b/utils/yangutils/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang
new file mode 100644
index 0000000..71d1947
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingWithHierarchicalTypeFailureScenario.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef Percentage {
+    type INT;
+    }
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type Ant:FirstClass;
+            }
+            typedef FirstClass {
+                type Ant:PassingClass;
+            }
+        }
+        typedef PassingClass {
+            type Percentage;
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
new file mode 100644
index 0000000..35c28b6
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypdefHierarchicalRefUnresolved.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef Percentage {
+    type P:Per;
+    }
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type FirstClass;
+            }
+            typedef FirstClass {
+                type PassingClass;
+            }
+        }
+        typedef PassingClass {
+            type Percentage;
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang
new file mode 100644
index 0000000..958dc23
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypdefHierarchicalReference.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef Percentage {
+    type int32;
+    }
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type FirstClass;
+            }
+            typedef FirstClass {
+                type PassingClass;
+            }
+        }
+        typedef PassingClass {
+            type Percentage;
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
new file mode 100644
index 0000000..038c7de
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypeWithSelfAndExternalPrefixMix.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef Percentage {
+    type int32;
+    }
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type Ant:FirstClass;
+            }
+            typedef FirstClass {
+                type P:PassingClass;
+            }
+        }
+        typedef PassingClass {
+            type Ant:Percentage;
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang
new file mode 100644
index 0000000..4f292b8
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfFileLinkingWithTypeWithSelfModulePrefix.yang
@@ -0,0 +1,22 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef Percentage {
+    type int32;
+    }
+    container ospf {
+        list valid {
+            key "invalid-interval";
+            leaf invalid-interval {
+                type Ant:FirstClass;
+            }
+            typedef FirstClass {
+                type PassingClass;
+            }
+        }
+        typedef PassingClass {
+            type Ant:Percentage;
+        }
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang b/utils/yangutils/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
new file mode 100644
index 0000000..b6b08a7
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfResolutionWhenTypeAndTypedefAtRootLevel.yang
@@ -0,0 +1,11 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    leaf invalid-interval {
+        type hello;
+    }
+    typedef hello {
+        type String;
+    }
+}
diff --git a/utils/yangutils/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang b/utils/yangutils/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang
new file mode 100644
index 0000000..499e10d
--- /dev/null
+++ b/utils/yangutils/src/test/resources/SelfResolutionWhenTypeReferredTypedefNotDefined.yang
@@ -0,0 +1,11 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    leaf invalid-interval {
+        type hello;
+    }
+    typedef hi {
+        type String;
+    }
+}
diff --git a/utils/yangutils/src/test/resources/UsesInList.yang b/utils/yangutils/src/test/resources/UsesInList.yang
index 6443cfa..c4fd47d 100644
--- a/utils/yangutils/src/test/resources/UsesInList.yang
+++ b/utils/yangutils/src/test/resources/UsesInList.yang
@@ -5,7 +5,7 @@
     list valid {
         key address;
         leaf address {
-            type ip;
+            type P:ip;
         }
         uses endpoint {
             description "grouping under test";
diff --git a/utils/yangutils/src/test/resources/ValidNotificationStatement.yang b/utils/yangutils/src/test/resources/ValidNotificationStatement.yang
index b96fc54..d588bb9 100644
--- a/utils/yangutils/src/test/resources/ValidNotificationStatement.yang
+++ b/utils/yangutils/src/test/resources/ValidNotificationStatement.yang
@@ -16,10 +16,10 @@
            }
         }
         leaf if-admin-status {
-           type admin-status;
+           type P:admin-status;
         }
         leaf if-oper-status {
-           type oper-status;
+           type P:oper-status;
         }
     }
 }
diff --git a/utils/yangutils/src/test/resources/processTypeDef.yang b/utils/yangutils/src/test/resources/processTypeDef.yang
new file mode 100644
index 0000000..2875752
--- /dev/null
+++ b/utils/yangutils/src/test/resources/processTypeDef.yang
@@ -0,0 +1,11 @@
+module Test {
+    yang-version 1;
+    namespace http://huawei.com;
+    prefix Ant;
+    typedef hello {
+        type String;
+    }
+    leaf invalid-interval {
+        type hello;
+    }
+}