[ONOS-4670] Removal of Data Model dependencies on Linker

Change-Id: I3f9c5af30198ea31d743e06cea1764dcb306ec32
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java
index c78aa1e..ce1922f 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LengthRestrictionListener.java
@@ -20,6 +20,7 @@
 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
 import org.onosproject.yangutils.datamodel.YangStringRestriction;
 import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -29,6 +30,7 @@
 import static org.onosproject.yangutils.datamodel.YangDataTypes.BINARY;
 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
 import static org.onosproject.yangutils.datamodel.YangDataTypes.STRING;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processLengthRestriction;
 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;
@@ -36,7 +38,6 @@
 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.ListenerValidation.checkStackIsNotEmpty;
-import static org.onosproject.yangutils.utils.RestrictionResolver.processLengthRestriction;
 import static org.onosproject.yangutils.utils.YangConstructType.LENGTH_DATA;
 import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
 
@@ -125,8 +126,16 @@
             throw parserException;
         }
 
-        YangRangeRestriction lengthRestriction = processLengthRestriction(null, ctx.getStart().getLine(),
-                ctx.getStart().getCharPositionInLine(), false, ctx.length().getText());
+        YangRangeRestriction lengthRestriction = null;
+        try {
+            lengthRestriction = processLengthRestriction(null, ctx.getStart().getLine(),
+                    ctx.getStart().getCharPositionInLine(), false, ctx.length().getText());
+        } catch (DataModelException e) {
+            ParserException parserException = new ParserException(e.getMessage());
+            parserException.setCharPosition(e.getCharPositionInLine());
+            parserException.setLine(e.getLineNumber());
+            throw parserException;
+        }
 
         if (type.getDataType() == STRING) {
             YangStringRestriction stringRestriction = (YangStringRestriction) type.getDataTypeExtendedInfo();
@@ -151,7 +160,7 @@
      * @param ctx      context object of the grammar rule
      */
     public static void processLengthRestrictionExit(TreeWalkListener listener,
-                                                   GeneratedYangParser.LengthStatementContext ctx) {
+                                                    GeneratedYangParser.LengthStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, LENGTH_DATA, ctx.length().getText(), EXIT);
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 afa9acd..b7536a6 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,11 +16,12 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import org.onosproject.yangutils.datamodel.ResolvableType;
 import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
 import org.onosproject.yangutils.datamodel.YangRevision;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.ResolvableType;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -29,8 +30,7 @@
 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangModuleNode;
 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.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;
@@ -75,7 +75,7 @@
      * (module), perform validations and update the data model tree.
      *
      * @param listener Listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processModuleEntry(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
 
@@ -106,7 +106,7 @@
      * validations and update the data model tree.
      *
      * @param listener Listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processModuleExit(TreeWalkListener listener, GeneratedYangParser.ModuleStatementContext ctx) {
 
@@ -123,10 +123,10 @@
             ((YangReferenceResolver) listener.getParsedDataStack()
                     .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
         } catch (DataModelException e) {
-            ParserException parserException = new ParserException(e.getMessage());
-            parserException.setLine(e.getLineNumber());
-            parserException.setCharPosition(e.getCharPositionInLine());
-            throw parserException;
+            LinkerException linkerException = new LinkerException(e.getMessage());
+            linkerException.setLine(e.getLineNumber());
+            linkerException.setCharPosition(e.getCharPositionInLine());
+            throw linkerException;
         }
     }
 }
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java
index b0387ae..a3b9a6a 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RangeRestrictionListener.java
@@ -19,12 +19,15 @@
 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
 import org.onosproject.yangutils.datamodel.YangRangeRestriction;
 import org.onosproject.yangutils.datamodel.YangType;
+import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
 
 import static org.onosproject.yangutils.datamodel.YangDataTypes.DERIVED;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.isOfRangeRestrictedType;
+import static org.onosproject.yangutils.datamodel.utils.RestrictionResolver.processRangeRestriction;
 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;
@@ -32,8 +35,6 @@
 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.ListenerValidation.checkStackIsNotEmpty;
-import static org.onosproject.yangutils.utils.RestrictionResolver.isOfRangeRestrictedType;
-import static org.onosproject.yangutils.utils.RestrictionResolver.processRangeRestriction;
 import static org.onosproject.yangutils.utils.YangConstructType.RANGE_DATA;
 import static org.onosproject.yangutils.utils.YangConstructType.TYPE_DATA;
 
@@ -95,8 +96,8 @@
      * Sets the range restriction to type.
      *
      * @param listener listener's object
-     * @param type YANG type for which range restriction to be added
-     * @param ctx  context object of the grammar rule
+     * @param type     YANG type for which range restriction to be added
+     * @param ctx      context object of the grammar rule
      */
     private static void setRangeRestriction(TreeWalkListener listener, YangType type,
                                             GeneratedYangParser.RangeStatementContext ctx) {
@@ -119,8 +120,16 @@
             throw parserException;
         }
 
-        YangRangeRestriction rangeRestriction = processRangeRestriction(null, ctx.getStart().getLine(),
-                ctx.getStart().getCharPositionInLine(), false, ctx.range().getText(), type.getDataType());
+        YangRangeRestriction rangeRestriction = null;
+        try {
+            rangeRestriction = processRangeRestriction(null, ctx.getStart().getLine(),
+                    ctx.getStart().getCharPositionInLine(), false, ctx.range().getText(), type.getDataType());
+        } catch (DataModelException e) {
+            ParserException parserException = new ParserException(e.getMessage());
+            parserException.setCharPosition(e.getCharPositionInLine());
+            parserException.setLine(e.getLineNumber());
+            throw parserException;
+        }
 
         if (rangeRestriction != null) {
             type.setDataTypeExtendedInfo(rangeRestriction);
@@ -133,10 +142,10 @@
      * It is called when parser exits from grammar rule (range).
      *
      * @param listener listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processRangeRestrictionExit(TreeWalkListener listener,
-                                       GeneratedYangParser.RangeStatementContext ctx) {
+                                                   GeneratedYangParser.RangeStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, RANGE_DATA, ctx.range().getText(), EXIT);
@@ -152,4 +161,4 @@
                     ctx.range().getText(), EXIT));
         }
     }
-}
\ No newline at end of file
+}
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 048e635..f489ecd 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,11 +16,12 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import org.onosproject.yangutils.datamodel.ResolvableType;
+import org.onosproject.yangutils.datamodel.YangReferenceResolver;
 import org.onosproject.yangutils.datamodel.YangRevision;
 import org.onosproject.yangutils.datamodel.YangSubModule;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.ResolvableType;
-import org.onosproject.yangutils.linker.YangReferenceResolver;
+import org.onosproject.yangutils.linker.exceptions.LinkerException;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 import org.onosproject.yangutils.parser.impl.TreeWalkListener;
@@ -29,8 +30,7 @@
 import static org.onosproject.yangutils.datamodel.utils.YangDataModelFactory.getYangSubModuleNode;
 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.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;
@@ -76,10 +76,10 @@
      * module), perform validations and update the data model tree.
      *
      * @param listener Listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processSubModuleEntry(TreeWalkListener listener,
-            GeneratedYangParser.SubModuleStatementContext ctx) {
+                                             GeneratedYangParser.SubModuleStatementContext ctx) {
 
         // Check if stack is empty.
         checkStackIsEmpty(listener, INVALID_HOLDER, SUB_MODULE_DATA, ctx.identifier().getText(),
@@ -109,10 +109,10 @@
      * validations and update the data model tree.
      *
      * @param listener Listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processSubModuleExit(TreeWalkListener listener,
-            GeneratedYangParser.SubModuleStatementContext ctx) {
+                                            GeneratedYangParser.SubModuleStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, SUB_MODULE_DATA, ctx.identifier().getText(),
@@ -128,10 +128,10 @@
             ((YangReferenceResolver) listener.getParsedDataStack().peek())
                     .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
         } catch (DataModelException e) {
-            ParserException parserException = new ParserException(e.getMessage());
-            parserException.setLine(e.getLineNumber());
-            parserException.setCharPosition(e.getCharPositionInLine());
-            throw parserException;
+            LinkerException linkerException = new LinkerException(e.getMessage());
+            linkerException.setLine(e.getLineNumber());
+            linkerException.setCharPosition(e.getCharPositionInLine());
+            throw linkerException;
         }
     }
 }
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 6e386da..73f91df 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
@@ -26,7 +26,7 @@
 import org.onosproject.yangutils.datamodel.YangTypeDef;
 import org.onosproject.yangutils.datamodel.YangUnion;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
+import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -131,7 +131,7 @@
                     type.setResolvableStatus(UNRESOLVED);
 
                     // Add resolution information to the list
-                    YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangType>(type,
+                    YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangType>(type,
                             (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
                     addToResolutionList(resolutionInfo, ctx);
                 }
@@ -161,8 +161,8 @@
                     ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
 
                     // Add resolution information to the list
-                    YangResolutionInfo resolutionInfo =
-                            new YangResolutionInfo<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
+                    YangResolutionInfoImpl resolutionInfo =
+                            new YangResolutionInfoImpl<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
                                     errorPosition);
                     addToResolutionList(resolutionInfo, ctx);
                 }
@@ -191,8 +191,8 @@
                     type.setResolvableStatus(UNRESOLVED);
 
                     // Add resolution information to the list
-                    YangResolutionInfo resolutionInfo =
-                            new YangResolutionInfo<YangType>(type, unionNode, errorLine, errorPosition);
+                    YangResolutionInfoImpl resolutionInfo =
+                            new YangResolutionInfoImpl<YangType>(type, unionNode, errorLine, errorPosition);
                     addToResolutionList(resolutionInfo, ctx);
                 }
 
@@ -214,8 +214,8 @@
                     type.setResolvableStatus(UNRESOLVED);
 
                     // Add resolution information to the list
-                    YangResolutionInfo resolutionInfo =
-                            new YangResolutionInfo<YangType>(type, typeDef, errorLine, errorPosition);
+                    YangResolutionInfoImpl resolutionInfo =
+                            new YangResolutionInfoImpl<YangType>(type, typeDef, errorLine, errorPosition);
                     addToResolutionList(resolutionInfo, ctx);
                 }
                 break;
@@ -256,7 +256,7 @@
      * @param resolutionInfo resolution information
      * @param ctx            context object of the grammar rule
      */
-    private static void addToResolutionList(YangResolutionInfo<YangType> resolutionInfo,
+    private static void addToResolutionList(YangResolutionInfoImpl<YangType> resolutionInfo,
                                             GeneratedYangParser.TypeStatementContext ctx) {
         try {
             addResolutionInfo(resolutionInfo);
diff --git a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java
index fd6523f..48c2c3b 100644
--- a/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java
+++ b/utils/yangutils/src/main/java/org/onosproject/yangutils/parser/impl/listeners/UsesListener.java
@@ -26,10 +26,10 @@
 import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
 import org.onosproject.yangutils.datamodel.YangNotification;
 import org.onosproject.yangutils.datamodel.YangOutput;
-import org.onosproject.yangutils.linker.impl.YangResolutionInfo;
 import org.onosproject.yangutils.datamodel.YangSubModule;
 import org.onosproject.yangutils.datamodel.YangUses;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
 import org.onosproject.yangutils.parser.Parsable;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -110,7 +110,7 @@
      * validations and updates the data model tree.
      *
      * @param listener listener's object
-     * @param ctx context object of the grammar rule
+     * @param ctx      context object of the grammar rule
      */
     public static void processUsesEntry(TreeWalkListener listener, GeneratedYangParser.UsesStatementContext ctx) {
 
@@ -160,7 +160,7 @@
      * @param ctx      context object of the grammar rule
      */
     public static void processUsesExit(TreeWalkListener listener,
-                                           GeneratedYangParser.UsesStatementContext ctx) {
+                                       GeneratedYangParser.UsesStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, USES_DATA, ctx.string().getText(), EXIT);
@@ -184,7 +184,7 @@
         }
 
         // Add resolution information to the list
-        YangResolutionInfo resolutionInfo = new YangResolutionInfo<YangUses>(uses,
+        YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangUses>(uses,
                 (YangNode) parentNode, errorLine,
                 errorPosition);
         addToResolutionList(resolutionInfo, ctx);
@@ -208,10 +208,10 @@
      * Add to resolution list.
      *
      * @param resolutionInfo resolution information.
-     * @param ctx context object of the grammar rule
+     * @param ctx            context object of the grammar rule
      */
-    private static void addToResolutionList(YangResolutionInfo<YangUses> resolutionInfo,
-            GeneratedYangParser.UsesStatementContext ctx) {
+    private static void addToResolutionList(YangResolutionInfoImpl<YangUses> resolutionInfo,
+                                            GeneratedYangParser.UsesStatementContext ctx) {
 
         try {
             addResolutionInfo(resolutionInfo);