[ONOS-4993] [ONOS-4956] [ONOS-4935] YANG interfile linker defect fix

Change-Id: I0037c9bd2a73b13a50bb874c7a72c6b2f5050e7e
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IdentityrefListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IdentityrefListener.java
index 49037e2..2d04602 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IdentityrefListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IdentityrefListener.java
@@ -33,11 +33,13 @@
 import static org.onosproject.yangutils.datamodel.utils.YangConstructType.IDENTITYREF_DATA;
 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.MISSING_HOLDER;
+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;
@@ -71,7 +73,7 @@
      * @param ctx      context object of the grammar rule
      */
     public static void processIdentityrefEntry(TreeWalkListener listener,
-                                        GeneratedYangParser.IdentityrefSpecificationContext ctx) {
+            GeneratedYangParser.IdentityrefSpecificationContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, IDENTITYREF_DATA, "", ENTRY);
@@ -85,7 +87,7 @@
 
             // Validate node identifier.
             YangNodeIdentifier nodeIdentifier = getValidNodeIdentifier(ctx.baseStatement().string().getText(),
-                                                                       BASE_DATA, ctx);
+                    BASE_DATA, ctx);
             identityRef.setBaseIdentity(nodeIdentifier);
             ((YangType) typeData).setDataTypeExtendedInfo(identityRef);
 
@@ -106,16 +108,17 @@
                     // Verify parent node of leaf
                     if (!(parentNodeOfLeaf instanceof YangNode)) {
                         throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER,
-                                                                                IDENTITYREF_DATA, ctx.getText(), EXIT));
+                                IDENTITYREF_DATA, ctx.getText(), EXIT));
                     }
 
                     identityRef.setResolvableStatus(UNRESOLVED);
 
-                    // Add resolution information to the list
-                    resolutionInfo =  new YangResolutionInfoImpl<YangIdentityRef>(identityRef,
-                                                  (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
-                    addToResolutionList(resolutionInfo, ctx);
-
+                    if (listener.getGroupingDepth() == 0) {
+                        // Add resolution information to the list
+                        resolutionInfo = new YangResolutionInfoImpl<YangIdentityRef>(identityRef,
+                                (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
+                        addToResolutionList(resolutionInfo, ctx);
+                    }
                     break;
                 case LEAF_LIST_DATA:
 
@@ -129,15 +132,17 @@
                     // Verify parent node of leaf
                     if (!(parentNodeOfLeafList instanceof YangNode)) {
                         throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER,
-                                                                                IDENTITYREF_DATA, ctx.getText(), EXIT));
+                                IDENTITYREF_DATA, ctx.getText(), EXIT));
                     }
 
                     identityRef.setResolvableStatus(UNRESOLVED);
 
-                    // Add resolution information to the list
-                    resolutionInfo = new YangResolutionInfoImpl<YangIdentityRef>(identityRef,
-                                               (YangNode) parentNodeOfLeafList, errorLine, errorPosition);
-                    addToResolutionList(resolutionInfo, ctx);
+                    if (listener.getGroupingDepth() == 0) {
+                        // Add resolution information to the list
+                        resolutionInfo = new YangResolutionInfoImpl<YangIdentityRef>(identityRef,
+                                (YangNode) parentNodeOfLeafList, errorLine, errorPosition);
+                        addToResolutionList(resolutionInfo, ctx);
+                    }
                     break;
                 case UNION_DATA:
 
@@ -146,16 +151,17 @@
                     // Verify parent node of leaf
                     if (!(parentNodeOfUnionNode instanceof YangNode)) {
                         throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER,
-                                                                                IDENTITYREF_DATA, ctx.getText(), EXIT));
+                                IDENTITYREF_DATA, ctx.getText(), EXIT));
                     }
 
                     identityRef.setResolvableStatus(UNRESOLVED);
 
-                    // Add resolution information to the list
-                    resolutionInfo = new YangResolutionInfoImpl<YangIdentityRef>(identityRef,
-                                              (YangNode) parentNodeOfUnionNode, errorLine, errorPosition);
-                    addToResolutionList(resolutionInfo, ctx);
-
+                    if (listener.getGroupingDepth() == 0) {
+                        // Add resolution information to the list
+                        resolutionInfo = new YangResolutionInfoImpl<YangIdentityRef>(identityRef,
+                                (YangNode) parentNodeOfUnionNode, errorLine, errorPosition);
+                        addToResolutionList(resolutionInfo, ctx);
+                    }
                     break;
                 case TYPEDEF_DATA:
                     /**
@@ -167,11 +173,11 @@
                     break;
                 default:
                     throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IDENTITYREF_DATA,
-                                                                            ctx.getText(), EXIT));
+                            ctx.getText(), EXIT));
             }
             listener.getParsedDataStack().push(typeData);
             listener.getParsedDataStack().push(identityRef);
-         } else {
+        } else {
             throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IDENTITYREF_DATA, "", ENTRY));
         }
     }
@@ -184,7 +190,7 @@
      * @param ctx      context object of the grammar rule
      */
     public static void processIdentityrefExit(TreeWalkListener listener,
-                                       GeneratedYangParser.IdentityrefSpecificationContext ctx) {
+            GeneratedYangParser.IdentityrefSpecificationContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_CURRENT_HOLDER, IDENTITYREF_DATA, ctx.getText(), EXIT);
@@ -192,7 +198,7 @@
         Parsable parsableType = listener.getParsedDataStack().pop();
         if (!(parsableType instanceof YangIdentityRef)) {
             throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IDENTITYREF_DATA,
-                                                                    ctx.getText(), EXIT));
+                    ctx.getText(), EXIT));
         }
     }
 
@@ -203,12 +209,12 @@
      * @param ctx            context object of the grammar rule
      */
     private static void addToResolutionList(YangResolutionInfoImpl<YangIdentityRef> resolutionInfo,
-                                            GeneratedYangParser.IdentityrefSpecificationContext ctx) {
+            GeneratedYangParser.IdentityrefSpecificationContext ctx) {
         try {
             addResolutionInfo(resolutionInfo);
         } catch (DataModelException e) {
             throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
-                                               IDENTITYREF_DATA, ctx.getText(), ENTRY, e.getMessage()));
+                    IDENTITYREF_DATA, ctx.getText(), ENTRY, e.getMessage()));
         }
     }
 }
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
index 972d1ef..c77ffea 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
@@ -17,6 +17,7 @@
 package org.onosproject.yangutils.parser.impl.listeners;
 
 import java.util.Date;
+
 import org.onosproject.yangutils.datamodel.ResolvableType;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangReferenceResolver;
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
index 3c7fba9..73b62b2 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/TypeListener.java
@@ -38,8 +38,10 @@
 import static org.onosproject.yangutils.datamodel.utils.YangConstructType.TYPE_DATA;
 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.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;
@@ -82,7 +84,7 @@
      * @param ctx      context object of the grammar rule
      */
     public static void processTypeEntry(TreeWalkListener listener,
-                                        GeneratedYangParser.TypeStatementContext ctx) {
+            GeneratedYangParser.TypeStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, TYPE_DATA, ctx.string().getText(), ENTRY);
@@ -136,10 +138,12 @@
 
                     type.setResolvableStatus(UNRESOLVED);
 
-                    // Add resolution information to the list
-                    YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangType>(type,
-                            (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
-                    addToResolutionList(resolutionInfo, ctx);
+                    if (listener.getGroupingDepth() == 0) {
+                        // Add resolution information to the list
+                        YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangType>(type,
+                                (YangNode) parentNodeOfLeaf, errorLine, errorPosition);
+                        addToResolutionList(resolutionInfo, ctx);
+                    }
                 }
                 break;
             case LEAF_LIST_DATA:
@@ -166,11 +170,13 @@
                     YangDerivedInfo<?> yangDerivedInfo = new YangDerivedInfo<>();
                     ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
 
-                    // Add resolution information to the list
-                    YangResolutionInfoImpl resolutionInfo =
-                            new YangResolutionInfoImpl<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
-                                    errorPosition);
-                    addToResolutionList(resolutionInfo, ctx);
+                    if (listener.getGroupingDepth() == 0) {
+                        // Add resolution information to the list
+                        YangResolutionInfoImpl resolutionInfo =
+                                new YangResolutionInfoImpl<YangType>(type, (YangNode) parentNodeOfLeafList, errorLine,
+                                        errorPosition);
+                        addToResolutionList(resolutionInfo, ctx);
+                    }
                 }
                 break;
             case UNION_DATA:
@@ -196,10 +202,12 @@
 
                     type.setResolvableStatus(UNRESOLVED);
 
-                    // Add resolution information to the list
-                    YangResolutionInfoImpl resolutionInfo =
-                            new YangResolutionInfoImpl<YangType>(type, unionNode, errorLine, errorPosition);
-                    addToResolutionList(resolutionInfo, ctx);
+                    if (listener.getGroupingDepth() == 0) {
+                        // Add resolution information to the list
+                        YangResolutionInfoImpl resolutionInfo =
+                                new YangResolutionInfoImpl<YangType>(type, unionNode, errorLine, errorPosition);
+                        addToResolutionList(resolutionInfo, ctx);
+                    }
                 }
 
                 break;
@@ -218,11 +226,12 @@
                     ((YangType<YangDerivedInfo>) type).setDataTypeExtendedInfo(yangDerivedInfo);
 
                     type.setResolvableStatus(UNRESOLVED);
-
-                    // Add resolution information to the list
-                    YangResolutionInfoImpl resolutionInfo =
-                            new YangResolutionInfoImpl<YangType>(type, typeDef, errorLine, errorPosition);
-                    addToResolutionList(resolutionInfo, ctx);
+                    if (listener.getGroupingDepth() == 0) {
+                        // Add resolution information to the list
+                        YangResolutionInfoImpl resolutionInfo =
+                                new YangResolutionInfoImpl<YangType>(type, typeDef, errorLine, errorPosition);
+                        addToResolutionList(resolutionInfo, ctx);
+                    }
                 }
                 break;
             //TODO: deviate replacement statement.
@@ -256,7 +265,7 @@
      * @param ctx      context object of the grammar rule
      */
     public static void processTypeExit(TreeWalkListener listener,
-                                       GeneratedYangParser.TypeStatementContext ctx) {
+            GeneratedYangParser.TypeStatementContext ctx) {
 
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_CURRENT_HOLDER, TYPE_DATA, ctx.string().getText(), EXIT);
@@ -275,7 +284,7 @@
      * @param ctx            context object of the grammar rule
      */
     private static void addToResolutionList(YangResolutionInfoImpl<YangType> resolutionInfo,
-                                            GeneratedYangParser.TypeStatementContext ctx) {
+            GeneratedYangParser.TypeStatementContext ctx) {
         try {
             addResolutionInfo(resolutionInfo);
         } catch (DataModelException e) {
@@ -291,7 +300,7 @@
      * @param yangDataType yang data type
      */
     private static void validateTypeSubStatementCardinality(GeneratedYangParser.TypeStatementContext ctx,
-                                                            YangDataTypes yangDataType) {
+            YangDataTypes yangDataType) {
         if (ctx.typeBodyStatements() == null || ctx.typeBodyStatements().isEmpty()) {
             ParserException parserException;
             switch (yangDataType) {
@@ -317,7 +326,7 @@
                     break;
                 case IDENTITYREF:
                     parserException = new ParserException("YANG file error : a type identityref" +
-                                                                  " must have base statement.");
+                            " must have base statement.");
                     break;
                 default:
                     return;