[ONOS-5135]config issue + augment flag

Change-Id: I56112023cfe64eecb16796a29ad0137952fbe49a
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
index 9c5745d..4ca9c5a 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
@@ -125,6 +125,34 @@
     private int groupingDepth;
 
     /**
+     * Parent depth of unsupported yang construct count for any node.
+     */
+    private int unsupportedYangConstructDepth;
+
+    /**
+     * Returns number of unsupported yang constructs parents, by a node, at any level.
+     *
+     * @return depth of unsupported yang constructs
+     */
+    public int getUnsupportedYangConstructDepth() {
+        return unsupportedYangConstructDepth;
+    }
+
+    /**
+     * Sets number of unsupported yang constructs by a node at any level.
+     */
+    private void increaseUnsupportedYangConstructDepth() {
+        unsupportedYangConstructDepth++;
+    }
+
+    /**
+     * Sets number of unsupported yang constructs by a node at any level.
+     */
+    private void decreaseUnsupportedYangConstructDepth() {
+        unsupportedYangConstructDepth--;
+    }
+
+    /**
      * Returns number of grouping parents, by a node, at any level.
      *
      * @return depth of grouping
@@ -373,7 +401,9 @@
 
     @Override
     public void enterDescriptionStatement(GeneratedYangParser.DescriptionStatementContext ctx) {
-        DescriptionListener.processDescriptionEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            DescriptionListener.processDescriptionEntry(this, ctx);
+        }
     }
 
     @Override
@@ -383,7 +413,9 @@
 
     @Override
     public void enterReferenceStatement(GeneratedYangParser.ReferenceStatementContext ctx) {
-        ReferenceListener.processReferenceEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            ReferenceListener.processReferenceEntry(this, ctx);
+        }
     }
 
     @Override
@@ -533,7 +565,9 @@
 
     @Override
     public void enterBaseStatement(GeneratedYangParser.BaseStatementContext ctx) {
-        BaseListener.processBaseEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            BaseListener.processBaseEntry(this, ctx);
+        }
     }
 
     @Override
@@ -573,7 +607,9 @@
 
     @Override
     public void enterIfFeatureStatement(GeneratedYangParser.IfFeatureStatementContext ctx) {
-        IfFeatureListener.processIfFeatureEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            IfFeatureListener.processIfFeatureEntry(this, ctx);
+        }
     }
 
     @Override
@@ -583,7 +619,9 @@
 
     @Override
     public void enterUnitsStatement(GeneratedYangParser.UnitsStatementContext ctx) {
-        UnitsListener.processUnitsEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            UnitsListener.processUnitsEntry(this, ctx);
+        }
     }
 
     @Override
@@ -603,12 +641,16 @@
 
     @Override
     public void enterTypeStatement(GeneratedYangParser.TypeStatementContext ctx) {
-        TypeListener.processTypeEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            TypeListener.processTypeEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitTypeStatement(GeneratedYangParser.TypeStatementContext ctx) {
-        TypeListener.processTypeExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            TypeListener.processTypeExit(this, ctx);
+        }
     }
 
     @Override
@@ -623,17 +665,23 @@
 
     @Override
     public void enterDecimal64Specification(GeneratedYangParser.Decimal64SpecificationContext ctx) {
-        Decimal64Listener.processDecimal64Entry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            Decimal64Listener.processDecimal64Entry(this, ctx);
+        }
     }
 
     @Override
     public void exitDecimal64Specification(GeneratedYangParser.Decimal64SpecificationContext ctx) {
-        Decimal64Listener.processDecimal64Exit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            Decimal64Listener.processDecimal64Exit(this, ctx);
+        }
     }
 
     @Override
     public void enterFractionDigitStatement(GeneratedYangParser.FractionDigitStatementContext ctx) {
-        FractionDigitsListener.processFractionDigitsEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            FractionDigitsListener.processFractionDigitsEntry(this, ctx);
+        }
     }
 
     @Override
@@ -653,12 +701,16 @@
 
     @Override
     public void enterRangeStatement(GeneratedYangParser.RangeStatementContext ctx) {
-        RangeRestrictionListener.processRangeRestrictionEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            RangeRestrictionListener.processRangeRestrictionEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitRangeStatement(GeneratedYangParser.RangeStatementContext ctx) {
-        RangeRestrictionListener.processRangeRestrictionExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            RangeRestrictionListener.processRangeRestrictionExit(this, ctx);
+        }
     }
 
     @Override
@@ -683,27 +735,37 @@
 
     @Override
     public void enterLengthStatement(GeneratedYangParser.LengthStatementContext ctx) {
-        LengthRestrictionListener.processLengthRestrictionEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            LengthRestrictionListener.processLengthRestrictionEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitLengthStatement(GeneratedYangParser.LengthStatementContext ctx) {
-        LengthRestrictionListener.processLengthRestrictionExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            LengthRestrictionListener.processLengthRestrictionExit(this, ctx);
+        }
     }
 
     @Override
     public void enterPatternStatement(GeneratedYangParser.PatternStatementContext ctx) {
-        PatternRestrictionListener.processPatternRestrictionEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            PatternRestrictionListener.processPatternRestrictionEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitPatternStatement(GeneratedYangParser.PatternStatementContext ctx) {
-        PatternRestrictionListener.processPatternRestrictionExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            PatternRestrictionListener.processPatternRestrictionExit(this, ctx);
+        }
     }
 
     @Override
     public void enterDefaultStatement(GeneratedYangParser.DefaultStatementContext ctx) {
-        DefaultListener.processDefaultEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            DefaultListener.processDefaultEntry(this, ctx);
+        }
     }
 
     @Override
@@ -713,22 +775,30 @@
 
     @Override
     public void enterEnumSpecification(GeneratedYangParser.EnumSpecificationContext ctx) {
-        EnumerationListener.processEnumerationEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            EnumerationListener.processEnumerationEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitEnumSpecification(GeneratedYangParser.EnumSpecificationContext ctx) {
-        EnumerationListener.processEnumerationExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            EnumerationListener.processEnumerationExit(this, ctx);
+        }
     }
 
     @Override
     public void enterEnumStatement(GeneratedYangParser.EnumStatementContext ctx) {
-        EnumListener.processEnumEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            EnumListener.processEnumEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitEnumStatement(GeneratedYangParser.EnumStatementContext ctx) {
-        EnumListener.processEnumExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            EnumListener.processEnumExit(this, ctx);
+        }
     }
 
     @Override
@@ -743,17 +813,23 @@
 
     @Override
     public void enterLeafrefSpecification(GeneratedYangParser.LeafrefSpecificationContext ctx) {
-        LeafrefListener.processLeafrefEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            LeafrefListener.processLeafrefEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitLeafrefSpecification(GeneratedYangParser.LeafrefSpecificationContext ctx) {
-        LeafrefListener.processLeafrefExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            LeafrefListener.processLeafrefExit(this, ctx);
+        }
     }
 
     @Override
     public void enterPathStatement(GeneratedYangParser.PathStatementContext ctx) {
-        PathListener.processPathEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            PathListener.processPathEntry(this, ctx);
+        }
     }
 
     @Override
@@ -763,7 +839,9 @@
 
     @Override
     public void enterRequireInstanceStatement(GeneratedYangParser.RequireInstanceStatementContext ctx) {
-        RequireInstanceListener.processRequireInstanceEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            RequireInstanceListener.processRequireInstanceEntry(this, ctx);
+        }
     }
 
     @Override
@@ -783,42 +861,58 @@
 
     @Override
     public void enterIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) {
-        IdentityrefListener.processIdentityrefEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            IdentityrefListener.processIdentityrefEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitIdentityrefSpecification(GeneratedYangParser.IdentityrefSpecificationContext ctx) {
-        IdentityrefListener.processIdentityrefExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            IdentityrefListener.processIdentityrefExit(this, ctx);
+        }
     }
 
     @Override
     public void enterUnionSpecification(GeneratedYangParser.UnionSpecificationContext ctx) {
-        UnionListener.processUnionEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            UnionListener.processUnionEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitUnionSpecification(GeneratedYangParser.UnionSpecificationContext ctx) {
-        UnionListener.processUnionExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            UnionListener.processUnionExit(this, ctx);
+        }
     }
 
     @Override
     public void enterBitsSpecification(GeneratedYangParser.BitsSpecificationContext ctx) {
-        BitsListener.processBitsEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            BitsListener.processBitsEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitBitsSpecification(GeneratedYangParser.BitsSpecificationContext ctx) {
-        BitsListener.processBitsExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            BitsListener.processBitsExit(this, ctx);
+        }
     }
 
     @Override
     public void enterBitStatement(GeneratedYangParser.BitStatementContext ctx) {
-        BitListener.processBitEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            BitListener.processBitEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitBitStatement(GeneratedYangParser.BitStatementContext ctx) {
-        BitListener.processBitExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            BitListener.processBitExit(this, ctx);
+        }
     }
 
     @Override
@@ -833,7 +927,9 @@
 
     @Override
     public void enterPositionStatement(GeneratedYangParser.PositionStatementContext ctx) {
-        PositionListener.processPositionEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            PositionListener.processPositionEntry(this, ctx);
+        }
     }
 
     @Override
@@ -843,7 +939,9 @@
 
     @Override
     public void enterStatusStatement(GeneratedYangParser.StatusStatementContext ctx) {
-        StatusListener.processStatusEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            StatusListener.processStatusEntry(this, ctx);
+        }
     }
 
     @Override
@@ -853,7 +951,9 @@
 
     @Override
     public void enterConfigStatement(GeneratedYangParser.ConfigStatementContext ctx) {
-        ConfigListener.processConfigEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            ConfigListener.processConfigEntry(this, ctx);
+        }
     }
 
     @Override
@@ -863,7 +963,9 @@
 
     @Override
     public void enterMandatoryStatement(GeneratedYangParser.MandatoryStatementContext ctx) {
-        MandatoryListener.processMandatoryEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            MandatoryListener.processMandatoryEntry(this, ctx);
+        }
     }
 
     @Override
@@ -873,7 +975,9 @@
 
     @Override
     public void enterPresenceStatement(GeneratedYangParser.PresenceStatementContext ctx) {
-        PresenceListener.processPresenceEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            PresenceListener.processPresenceEntry(this, ctx);
+        }
     }
 
     @Override
@@ -893,17 +997,23 @@
 
     @Override
     public void enterMustStatement(GeneratedYangParser.MustStatementContext ctx) {
-        MustListener.processMustEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            MustListener.processMustEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitMustStatement(GeneratedYangParser.MustStatementContext ctx) {
-        MustListener.processMustExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            MustListener.processMustExit(this, ctx);
+        }
     }
 
     @Override
     public void enterErrorMessageStatement(GeneratedYangParser.ErrorMessageStatementContext ctx) {
-        ErrorMessageListener.processErrorMessageEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            ErrorMessageListener.processErrorMessageEntry(this, ctx);
+        }
     }
 
     @Override
@@ -913,7 +1023,9 @@
 
     @Override
     public void enterErrorAppTagStatement(GeneratedYangParser.ErrorAppTagStatementContext ctx) {
-        ErrorAppTagListener.processErrorAppTagMessageEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            ErrorAppTagListener.processErrorAppTagMessageEntry(this, ctx);
+        }
     }
 
     @Override
@@ -923,7 +1035,9 @@
 
     @Override
     public void enterMinElementsStatement(GeneratedYangParser.MinElementsStatementContext ctx) {
-        MinElementsListener.processMinElementsEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            MinElementsListener.processMinElementsEntry(this, ctx);
+        }
     }
 
     @Override
@@ -933,7 +1047,9 @@
 
     @Override
     public void enterMaxElementsStatement(GeneratedYangParser.MaxElementsStatementContext ctx) {
-        MaxElementsListener.processMaxElementsEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            MaxElementsListener.processMaxElementsEntry(this, ctx);
+        }
     }
 
     @Override
@@ -943,7 +1059,9 @@
 
     @Override
     public void enterValueStatement(GeneratedYangParser.ValueStatementContext ctx) {
-        ValueListener.processValueEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            ValueListener.processValueEntry(this, ctx);
+        }
     }
 
     @Override
@@ -1013,7 +1131,9 @@
 
     @Override
     public void enterUniqueStatement(GeneratedYangParser.UniqueStatementContext ctx) {
-        UniqueListener.processUniqueEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            UniqueListener.processUniqueEntry(this, ctx);
+        }
     }
 
     @Override
@@ -1053,12 +1173,13 @@
 
     @Override
     public void enterAnyxmlStatement(GeneratedYangParser.AnyxmlStatementContext ctx) {
+        increaseUnsupportedYangConstructDepth();
         handleUnsupportedYangConstruct(YangConstructType.ANYXML_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT, getFileName());
     }
 
     @Override
     public void exitAnyxmlStatement(GeneratedYangParser.AnyxmlStatementContext ctx) {
-        // do nothing.
+        decreaseUnsupportedYangConstructDepth();
     }
 
     @Override
@@ -1073,12 +1194,13 @@
 
     @Override
     public void enterRefineStatement(GeneratedYangParser.RefineStatementContext ctx) {
+        increaseUnsupportedYangConstructDepth();
         handleUnsupportedYangConstruct(YangConstructType.REFINE_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT, getFileName());
     }
 
     @Override
     public void exitRefineStatement(GeneratedYangParser.RefineStatementContext ctx) {
-        // do nothing.
+        decreaseUnsupportedYangConstructDepth();
     }
 
     @Override
@@ -1163,12 +1285,16 @@
 
     @Override
     public void enterWhenStatement(GeneratedYangParser.WhenStatementContext ctx) {
-        WhenListener.processWhenEntry(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            WhenListener.processWhenEntry(this, ctx);
+        }
     }
 
     @Override
     public void exitWhenStatement(GeneratedYangParser.WhenStatementContext ctx) {
-        WhenListener.processWhenExit(this, ctx);
+        if (getUnsupportedYangConstructDepth() == 0) {
+            WhenListener.processWhenExit(this, ctx);
+        }
     }
 
     @Override
@@ -1213,13 +1339,14 @@
 
     @Override
     public void enterDeviationStatement(GeneratedYangParser.DeviationStatementContext ctx) {
+        increaseUnsupportedYangConstructDepth();
         handleUnsupportedYangConstruct(YangConstructType.DEVIATION_DATA, ctx, UNSUPPORTED_YANG_CONSTRUCT,
                 getFileName());
     }
 
     @Override
     public void exitDeviationStatement(GeneratedYangParser.DeviationStatementContext ctx) {
-        // do nothing.
+        decreaseUnsupportedYangConstructDepth();
     }
 
     @Override
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ChoiceListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ChoiceListener.java
index 1bfee32..e07dca6 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ChoiceListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ChoiceListener.java
@@ -33,6 +33,7 @@
 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.parser.impl.parserutils.ListenerValidation;
 
 import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
 import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CHOICE_DATA;
@@ -129,6 +130,15 @@
             YangChoice choiceNode = getYangChoiceNode(JAVA_GENERATION);
             choiceNode.setName(identifier);
 
+            /*
+             * If "config" is not specified, the default is the same as the parent
+             * schema node's "config" value.
+             */
+            if (ctx.configStatement().isEmpty()) {
+                boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
+                choiceNode.setConfig(parentConfig);
+            }
+
             YangNode curNode = (YangNode) curData;
             try {
                 curNode.addChild(choiceNode);
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
index 6850c62..70ff42a 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListener.java
@@ -22,6 +22,7 @@
 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.parser.impl.parserutils.ListenerValidation;
 
 import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
 import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CONFIG_DATA;
@@ -111,6 +112,15 @@
         YangLeafList leafList = getYangLeafList(JAVA_GENERATION);
         leafList.setLeafName(identifier);
 
+        /*
+         * If "config" is not specified, the default is the same as the parent
+         * schema node's "config" value.
+         */
+        if (ctx.configStatement().isEmpty()) {
+            boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
+            leafList.setConfig(parentConfig);
+        }
+
         Parsable tmpData = listener.getParsedDataStack().peek();
         YangLeavesHolder leavesHolder;
 
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
index ed100a0..8c66183 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/LeafListener.java
@@ -27,6 +27,7 @@
 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.parser.impl.parserutils.ListenerValidation;
 
 import static org.onosproject.yangutils.datamodel.utils.GeneratedLanguage.JAVA_GENERATION;
 import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CONFIG_DATA;
@@ -115,6 +116,15 @@
         YangLeaf leaf = getYangLeaf(JAVA_GENERATION);
         leaf.setLeafName(identifier);
 
+        /*
+         * If "config" is not specified, the default is the same as the parent
+         * schema node's "config" value.
+         */
+        if (ctx.configStatement().isEmpty()) {
+            boolean parentConfig = ListenerValidation.getParentNodeConfig(listener);
+            leaf.setConfig(parentConfig);
+        }
+
         Parsable tmpData = listener.getParsedDataStack().peek();
         YangLeavesHolder leavesHolder;
 
diff --git a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
index 188e24e..fa3b200 100644
--- a/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
+++ b/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerValidation.java
@@ -20,9 +20,14 @@
 import java.util.List;
 
 import org.antlr.v4.runtime.ParserRuleContext;
-import org.onosproject.yangutils.datamodel.YangContainer;
-import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangCase;
+import org.onosproject.yangutils.datamodel.YangChoice;
+import org.onosproject.yangutils.datamodel.YangConfig;
+import org.onosproject.yangutils.datamodel.YangInput;
 import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNotification;
+import org.onosproject.yangutils.datamodel.YangOutput;
+import org.onosproject.yangutils.datamodel.YangRpc;
 import org.onosproject.yangutils.datamodel.utils.Parsable;
 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -102,18 +107,18 @@
      * @return true/false parent's config value
      */
     public static boolean getParentNodeConfig(TreeWalkListener listener) {
-
-        YangNode parentNode;
         Parsable curData = listener.getParsedDataStack().peek();
-        if (curData instanceof YangNode) {
-            parentNode = ((YangNode) curData).getParent();
-            if (parentNode instanceof YangContainer) {
-                return ((YangContainer) parentNode).isConfig();
-            } else if (parentNode instanceof YangList) {
-                return ((YangList) parentNode).isConfig();
-            }
+        YangNode parentNode = ((YangNode) curData).getParent();
+        if (curData instanceof YangConfig) {
+            return ((YangConfig) curData).isConfig();
+        } else if (curData instanceof YangRpc || curData instanceof YangOutput
+                || curData instanceof YangInput || curData instanceof YangNotification) {
+            return false;
+        } else if (curData instanceof YangCase && parentNode instanceof YangChoice) {
+            return ((YangChoice) parentNode).isConfig();
+        } else {
+            return true;
         }
-        return true;
     }
 
     /**