[ONOS-4650][ONOS-4726][ONOS-4727] [ONOS-4728]Implement must parser + when parser + feature + if-feature + revision defect fix

Change-Id: I0a3aee6c1c6b72ef7da7f7f565fd0f149fe3fd42
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfoImpl.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfoImpl.java
index 6b6be58..17285f6 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfoImpl.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangEntityToResolveInfoImpl.java
@@ -18,6 +18,7 @@
 import java.io.Serializable;
 
 import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo;
+import org.onosproject.yangutils.datamodel.YangIfFeature;
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.datamodel.YangType;
 import org.onosproject.yangutils.datamodel.YangUses;
@@ -76,6 +77,8 @@
             prefix = ((YangType<?>) entityToBeResolved).getPrefix();
         } else if (entityToBeResolved instanceof YangUses) {
             prefix = ((YangUses) entityToBeResolved).getPrefix();
+        } else if (entityToBeResolved instanceof YangIfFeature) {
+            prefix = ((YangIfFeature) entityToBeResolved).getPrefix();
         } else {
             throw new LinkerException("Linker Exception: Entity to resolved is other than type/uses");
         }
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
index 96e1bcc..dc321bd 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangLinkerManager.java
@@ -156,6 +156,8 @@
             throws LinkerException {
         for (YangNode yangNode : yangNodeSet) {
             try {
+                ((YangReferenceResolver) yangNode)
+                        .resolveInterFileLinking(ResolvableType.YANG_IF_FEATURE);
                 ((YangReferenceResolver) yangNode).resolveInterFileLinking(ResolvableType.YANG_USES);
                 ((YangReferenceResolver) yangNode)
                         .resolveInterFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfoImpl.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfoImpl.java
index 2a710dc..0b5a464 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfoImpl.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/linker/impl/YangResolutionInfoImpl.java
@@ -17,15 +17,22 @@
 package org.onosproject.yangutils.linker.impl;
 
 import java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Stack;
 
 import org.onosproject.yangutils.datamodel.Resolvable;
 import org.onosproject.yangutils.datamodel.YangDataTypes;
 import org.onosproject.yangutils.datamodel.YangDerivedInfo;
+import org.onosproject.yangutils.datamodel.YangEntityToResolveInfo;
+import org.onosproject.yangutils.datamodel.YangFeature;
+import org.onosproject.yangutils.datamodel.YangFeatureHolder;
 import org.onosproject.yangutils.datamodel.YangGrouping;
+import org.onosproject.yangutils.datamodel.YangIfFeature;
 import org.onosproject.yangutils.datamodel.YangImport;
 import org.onosproject.yangutils.datamodel.YangInclude;
 import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeIdentifier;
 import org.onosproject.yangutils.datamodel.YangReferenceResolver;
 import org.onosproject.yangutils.datamodel.YangResolutionInfo;
 import org.onosproject.yangutils.datamodel.YangType;
@@ -39,9 +46,11 @@
 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED;
 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.LINKED;
 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNDEFINED;
 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNRESOLVED;
 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTER_FILE;
 import static org.onosproject.yangutils.linker.YangLinkingPhase.INTRA_FILE;
+import static org.onosproject.yangutils.utils.UtilConstants.FEATURE_LINKER_ERROR;
 import static org.onosproject.yangutils.utils.UtilConstants.GROUPING_LINKER_ERROR;
 import static org.onosproject.yangutils.utils.UtilConstants.TYPEDEF_LINKER_ERROR;
 
@@ -64,7 +73,7 @@
     /**
      * Error line number.
      */
-    private  transient int lineNumber;
+    private transient int lineNumber;
 
     /**
      * Error character position in number.
@@ -115,7 +124,7 @@
 
         setCurReferenceResolver(dataModelRootNode);
 
-        // Current node to resolve, it can be a YANG type or YANG uses.
+        // Current node to resolve, it can be a YANG type, YANG uses or YANG if-feature.
         T entityToResolve = getEntityToResolveInfo().getEntityToResolve();
 
         // Check if linking is already done
@@ -128,7 +137,8 @@
                 return;
             }
         } else {
-            throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
+            throw new DataModelException("Data Model Exception: Entity to resolved is other than " +
+                    "type/uses/if-feature");
         }
 
         // Push the initial entity to resolve in stack.
@@ -154,57 +164,60 @@
 
                 Resolvable resolvable = (Resolvable) entityToResolve;
                 switch (resolvable.getResolvableStatus()) {
-                case RESOLVED: {
-                    /*
-                     * If the entity is already resolved in the stack, then pop
-                     * it and continue with the remaining stack elements to
-                     * resolve
-                     */
-                    getPartialResolvedStack().pop();
-                    break;
-                }
-
-                case LINKED: {
-                    /*
-                     * If the top of the stack is already linked then resolve
-                     * the references and pop the entity and continue with
-                     * remaining stack elements to resolve.
-                     */
-                    resolveTopOfStack(INTRA_FILE);
-                    getPartialResolvedStack().pop();
-                    break;
-                }
-
-                case INTRA_FILE_RESOLVED: {
-                    /*
-                     * Pop the top of the stack.
-                     */
-                    getPartialResolvedStack().pop();
-                    break;
-                }
-
-                case UNRESOLVED: {
-                    linkTopOfStackReferenceUpdateStack();
-
-                    if (resolvable.getResolvableStatus() == UNRESOLVED) {
-                        // If current entity is still not resolved, then
-                        // linking/resolution has failed.
-                        String errorInfo;
-                        if (resolvable instanceof YangType) {
-                            errorInfo = TYPEDEF_LINKER_ERROR;
-                        } else {
-                            errorInfo = GROUPING_LINKER_ERROR;
-                        }
-                        DataModelException dataModelException = new DataModelException(errorInfo);
-                        dataModelException.setLine(getLineNumber());
-                        dataModelException.setCharPosition(getCharPosition());
-                        throw dataModelException;
+                    case RESOLVED: {
+                        /*
+                         * If the entity is already resolved in the stack, then pop
+                         * it and continue with the remaining stack elements to
+                         * resolve
+                         */
+                        getPartialResolvedStack().pop();
+                        break;
                     }
-                    break;
-                }
-                default: {
-                    throw new DataModelException("Data Model Exception: Unsupported, linker state");
-                }
+
+                    case LINKED: {
+                        /*
+                         * If the top of the stack is already linked then resolve
+                         * the references and pop the entity and continue with
+                         * remaining stack elements to resolve.
+                         */
+                        resolveTopOfStack(INTRA_FILE);
+                        getPartialResolvedStack().pop();
+                        break;
+                    }
+
+                    case INTRA_FILE_RESOLVED: {
+                        /*
+                         * Pop the top of the stack.
+                         */
+                        getPartialResolvedStack().pop();
+                        break;
+                    }
+
+                    case UNRESOLVED: {
+                        linkTopOfStackReferenceUpdateStack();
+
+                        if (resolvable.getResolvableStatus() == UNRESOLVED) {
+                            // If current entity is still not resolved, then
+                            // linking/resolution has failed.
+                            String errorInfo;
+                            if (resolvable instanceof YangType) {
+                                errorInfo = TYPEDEF_LINKER_ERROR;
+                            } else if (resolvable instanceof YangUses) {
+                                errorInfo = GROUPING_LINKER_ERROR;
+                            } else {
+                                errorInfo = FEATURE_LINKER_ERROR;
+                            }
+                            DataModelException dataModelException =
+                                    new DataModelException(errorInfo);
+                            dataModelException.setLine(getLineNumber());
+                            dataModelException.setCharPosition(getCharPosition());
+                            throw dataModelException;
+                        }
+                        break;
+                    }
+                    default: {
+                        throw new DataModelException("Data Model Exception: Unsupported, linker state");
+                    }
 
                 }
 
@@ -222,8 +235,9 @@
     private void resolveTopOfStack(YangLinkingPhase linkingPhase)
             throws DataModelException {
         ((Resolvable) getCurrentEntityToResolveFromStack()).resolve();
-        if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus() != INTRA_FILE_RESOLVED) {
-            // Sets the resolution status in inside the type/uses.
+        if (((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus() != INTRA_FILE_RESOLVED
+                && ((Resolvable) getCurrentEntityToResolveFromStack()).getResolvableStatus() != UNDEFINED) {
+            // Sets the resolution status in inside the type/uses/if-feature.
             ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(RESOLVED);
         }
     }
@@ -253,21 +267,27 @@
         YangNode potentialAncestorWithReferredNode = getPartialResolvedStack().peek()
                 .getHolderOfEntityToResolve();
 
-        /**
-         * Traverse up in the ancestor tree to check if the referred node is
-         * defined
-         */
-        while (potentialAncestorWithReferredNode != null) {
+        if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+            resolveSelfFileLinkingForIfFeature(potentialAncestorWithReferredNode);
+            return;
+        } else {
 
             /**
-             * Check for the referred node defined in a ancestor scope
+             * Traverse up in the ancestor tree to check if the referred node is
+             * defined
              */
-            YangNode potentialReferredNode = potentialAncestorWithReferredNode.getChild();
-            if (isReferredNodeInSiblingListProcessed(potentialReferredNode)) {
-                return;
-            }
+            while (potentialAncestorWithReferredNode != null) {
 
-            potentialAncestorWithReferredNode = potentialAncestorWithReferredNode.getParent();
+                /**
+                 * Check for the referred node defined in a ancestor scope
+                 */
+                YangNode potentialReferredNode = potentialAncestorWithReferredNode.getChild();
+                if (isReferredNodeInSiblingListProcessed(potentialReferredNode)) {
+                    return;
+                }
+
+                potentialAncestorWithReferredNode = potentialAncestorWithReferredNode.getParent();
+            }
         }
 
         /*
@@ -280,6 +300,56 @@
     }
 
     /**
+     * Resolves self file linking for if-feature.
+     *
+     * @param potentialAncestorWithReferredNode if-feature holder node
+     * @throws DataModelException DataModelException a violation of data model
+     *                            rules
+     */
+    private void resolveSelfFileLinkingForIfFeature(YangNode potentialAncestorWithReferredNode)
+            throws DataModelException {
+
+        YangFeatureHolder featureHolder = getFeatureHolder(potentialAncestorWithReferredNode);
+        YangNode potentialReferredNode = (YangNode) featureHolder;
+        if (isReferredNode(potentialReferredNode)) {
+
+            // Adds reference link of entity to the node under resolution.
+            addReferredEntityLink(potentialReferredNode, LINKED);
+
+            /**
+             * resolve the reference and update the partial resolution stack
+             * with any further recursive references
+             */
+            addUnresolvedRecursiveReferenceToStack(potentialReferredNode);
+            return;
+        }
+
+        /*
+         * In case prefix is not present it's a candidate for inter-file
+         * resolution via include list.
+         */
+        if (getRefPrefix() == null) {
+            ((Resolvable) getCurrentEntityToResolveFromStack()).setResolvableStatus(INTRA_FILE_RESOLVED);
+        }
+    }
+
+
+    /**
+     * Returns feature holder(module/sub-module node) .
+     *
+     * @param potentialAncestorWithReferredNode if-feature holder node
+     */
+    private YangFeatureHolder getFeatureHolder(YangNode potentialAncestorWithReferredNode) {
+        while (potentialAncestorWithReferredNode != null) {
+            if (potentialAncestorWithReferredNode instanceof YangFeatureHolder) {
+                return (YangFeatureHolder) potentialAncestorWithReferredNode;
+            }
+            potentialAncestorWithReferredNode = potentialAncestorWithReferredNode.getParent();
+        }
+        return null;
+    }
+
+    /**
      * Checks if the reference in self file or in external file.
      *
      * @return true if self file reference, false otherwise
@@ -352,6 +422,14 @@
                  */
                 return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
             }
+        } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+            if (potentialReferredNode instanceof YangFeatureHolder) {
+                /*
+                 * Check if name of node name matches with the entity being
+                 * resolved
+                 */
+                return isNodeNameSameAsResolutionInfoName(potentialReferredNode);
+            }
         } else {
             throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
         }
@@ -381,12 +459,31 @@
                     ((YangUses) getCurrentEntityToResolveFromStack()).getName())) {
                 return true;
             }
+        } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+            return isFeatureDefinedInNode(node);
         } else {
             throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
         }
         return false;
     }
 
+    private boolean isFeatureDefinedInNode(YangNode node) throws DataModelException {
+        YangNodeIdentifier ifFeature = ((YangIfFeature) getCurrentEntityToResolveFromStack()).getName();
+        List<YangFeature> featureList = ((YangFeatureHolder) node).getFeatureList();
+        if (featureList != null && !featureList.isEmpty()) {
+            Iterator<YangFeature> iterator = featureList.iterator();
+            while (iterator.hasNext()) {
+                YangFeature feature = iterator.next();
+                if (ifFeature.getName().equals(feature.getName())) {
+                    ((YangIfFeature) getCurrentEntityToResolveFromStack()).setReferredFeature(feature);
+                    ((YangIfFeature) getCurrentEntityToResolveFromStack()).setReferredFeatureHolder(node);
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
     /**
      * Adds reference of grouping/typedef in uses/type.
      *
@@ -403,6 +500,8 @@
         } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
             ((YangUses) getCurrentEntityToResolveFromStack())
                     .setRefGroup((YangGrouping) referredNode);
+        } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+            // do nothing , referred node is already set
         } else {
             throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
         }
@@ -440,6 +539,8 @@
              * return true, else return false.
              */
             addUnResolvedUsesToStack(referredNode);
+        } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+            addUnResolvedIfFeatureToStack(referredNode);
         } else {
             throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
         }
@@ -469,6 +570,26 @@
     }
 
     /**
+     * Returns if there is any unresolved if-feature in feature.
+     *
+     * @param node module/submodule node
+     */
+    private void addUnResolvedIfFeatureToStack(YangNode node) {
+        YangFeature refFeature = ((YangIfFeature) getCurrentEntityToResolveFromStack()).getReferredFeature();
+        List<YangIfFeature> ifFeatureList = refFeature.getIfFeatureList();
+        if (ifFeatureList != null && !ifFeatureList.isEmpty()) {
+            Iterator<YangIfFeature> ifFeatureIterator = ifFeatureList.iterator();
+            while (ifFeatureIterator.hasNext()) {
+                YangIfFeature ifFeature = ifFeatureIterator.next();
+                YangEntityToResolveInfo<YangIfFeature> unResolvedEntityInfo = new YangEntityToResolveInfoImpl<>();
+                unResolvedEntityInfo.setEntityToResolve(ifFeature);
+                unResolvedEntityInfo.setHolderOfEntityToResolve(node);
+                addInPartialResolvedStack((YangEntityToResolveInfoImpl<T>) unResolvedEntityInfo);
+            }
+        }
+    }
+
+    /**
      * Returns stack of YANG type with partially resolved YANG construct
      * hierarchy.
      *
@@ -600,6 +721,8 @@
             refPrefix = ((YangType<?>) getCurrentEntityToResolveFromStack()).getPrefix();
         } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
             refPrefix = ((YangUses) getCurrentEntityToResolveFromStack()).getPrefix();
+        } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+            refPrefix = ((YangIfFeature) getCurrentEntityToResolveFromStack()).getPrefix();
         } else {
             throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
         }
@@ -623,41 +746,50 @@
 
                 Resolvable resolvable = (Resolvable) entityToResolve;
                 switch (resolvable.getResolvableStatus()) {
-                case RESOLVED: {
-                    /*
-                     * If the entity is already resolved in the stack, then pop
-                     * it and continue with the remaining stack elements to
-                     * resolve
-                     */
-                    getPartialResolvedStack().pop();
-                    break;
-                }
+                    case RESOLVED: {
+                        /*
+                         * If the entity is already resolved in the stack, then pop
+                         * it and continue with the remaining stack elements to
+                         * resolve
+                         */
+                        getPartialResolvedStack().pop();
+                        break;
+                    }
 
-                case INTER_FILE_LINKED: {
-                    /*
-                     * If the top of the stack is already linked then resolve
-                     * the references and pop the entity and continue with
-                     * remaining stack elements to resolve
-                     */
-                    resolveTopOfStack(INTER_FILE);
-                    getPartialResolvedStack().pop();
-                    break;
-                }
+                    case INTER_FILE_LINKED: {
+                        /*
+                         * If the top of the stack is already linked then resolve
+                         * the references and pop the entity and continue with
+                         * remaining stack elements to resolve
+                         */
+                        resolveTopOfStack(INTER_FILE);
+                        getPartialResolvedStack().pop();
+                        break;
+                    }
 
-                case INTRA_FILE_RESOLVED: {
-                    /*
-                     * If the top of the stack is intra file resolved then check
-                     * if top of stack is linked, if not link it using
-                     * import/include list and push the linked referred entity
-                     * to the stack, otherwise only push it to the stack.
-                     */
-                    linkInterFileTopOfStackRefUpdateStack();
-                    break;
-                }
+                    case INTRA_FILE_RESOLVED: {
+                        /*
+                         * If the top of the stack is intra file resolved then check
+                         * if top of stack is linked, if not link it using
+                         * import/include list and push the linked referred entity
+                         * to the stack, otherwise only push it to the stack.
+                         */
+                        linkInterFileTopOfStackRefUpdateStack();
+                        break;
+                    }
 
-                default: {
-                    throw new DataModelException("Data Model Exception: Unsupported, linker state");
-                }
+                    case UNDEFINED: {
+                        /*
+                         * In case of if-feature resolution, if referred "feature" is not
+                         * defined then the resolvable status will be undefined.
+                         */
+                        getPartialResolvedStack().pop();
+                        break;
+                    }
+
+                    default: {
+                        throw new DataModelException("Data Model Exception: Unsupported, linker state");
+                    }
 
                 }
 
@@ -701,6 +833,11 @@
                     return;
                 }
             }
+
+            if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+                ((YangIfFeature) getCurrentEntityToResolveFromStack()).setResolvableStatus(UNDEFINED);
+                return;
+            }
             // Exception when referred typedef/grouping is not found.
             DataModelException dataModelException = new DataModelException("YANG file error: Referred " +
                     "typedef/grouping for a given type/uses can't be found.");
@@ -735,6 +872,8 @@
                 linkedNode = findRefTypedef(yangInclude.getIncludedNode());
             } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
                 linkedNode = findRefGrouping(yangInclude.getIncludedNode());
+            } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+                linkedNode = findRefFeature(yangInclude.getIncludedNode());
             }
             if (linkedNode != null) {
                 // Add the link to external entity.
@@ -776,6 +915,8 @@
                     linkedNode = findRefTypedef(yangImport.getImportedNode());
                 } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
                     linkedNode = findRefGrouping(yangImport.getImportedNode());
+                } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+                    linkedNode = findRefFeature(yangImport.getImportedNode());
                 }
                 if (linkedNode != null) {
                     // Add the link to external entity.
@@ -816,6 +957,8 @@
             return (T) derivedInfo.getReferredTypeDef();
         } else if (getCurrentEntityToResolveFromStack() instanceof YangUses) {
             return (T) ((YangUses) getCurrentEntityToResolveFromStack()).getRefGroup();
+        } else if (getCurrentEntityToResolveFromStack() instanceof YangIfFeature) {
+            return (T) ((YangIfFeature) getCurrentEntityToResolveFromStack()).getReferredFeatureHolder();
         } else {
             throw new DataModelException("Data Model Exception: Entity to resolved is other than type/uses");
         }
@@ -842,6 +985,29 @@
     }
 
     /**
+     * Finds the referred feature node at the root level of imported/included node.
+     *
+     * @param refNode module/sub-module node
+     * @return referred feature
+     */
+    private YangNode findRefFeature(YangNode refNode) {
+        YangNodeIdentifier ifFeature = ((YangIfFeature) getCurrentEntityToResolveFromStack()).getName();
+        List<YangFeature> featureList = ((YangFeatureHolder) refNode).getFeatureList();
+
+        if (featureList != null && !featureList.isEmpty()) {
+            Iterator<YangFeature> iterator = featureList.iterator();
+            while (iterator.hasNext()) {
+                YangFeature feature = iterator.next();
+                if (ifFeature.getName().equals(feature.getName())) {
+                    ((YangIfFeature) getCurrentEntityToResolveFromStack()).setReferredFeature(feature);
+                    return refNode;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
      * Finds the referred typedef node at the root level of imported/included node.
      *
      * @param refNode module/sub-module node
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
index 194d32f..8f08842 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/TreeWalkListener.java
@@ -40,7 +40,9 @@
 import org.onosproject.yangutils.parser.impl.listeners.DescriptionListener;
 import org.onosproject.yangutils.parser.impl.listeners.EnumListener;
 import org.onosproject.yangutils.parser.impl.listeners.EnumerationListener;
+import org.onosproject.yangutils.parser.impl.listeners.FeatureListener;
 import org.onosproject.yangutils.parser.impl.listeners.GroupingListener;
+import org.onosproject.yangutils.parser.impl.listeners.IfFeatureListener;
 import org.onosproject.yangutils.parser.impl.listeners.ImportListener;
 import org.onosproject.yangutils.parser.impl.listeners.IncludeListener;
 import org.onosproject.yangutils.parser.impl.listeners.InputListener;
@@ -53,6 +55,7 @@
 import org.onosproject.yangutils.parser.impl.listeners.MaxElementsListener;
 import org.onosproject.yangutils.parser.impl.listeners.MinElementsListener;
 import org.onosproject.yangutils.parser.impl.listeners.ModuleListener;
+import org.onosproject.yangutils.parser.impl.listeners.MustListener;
 import org.onosproject.yangutils.parser.impl.listeners.NotificationListener;
 import org.onosproject.yangutils.parser.impl.listeners.NamespaceListener;
 import org.onosproject.yangutils.parser.impl.listeners.OrganizationListener;
@@ -76,6 +79,7 @@
 import org.onosproject.yangutils.parser.impl.listeners.UsesListener;
 import org.onosproject.yangutils.parser.impl.listeners.ValueListener;
 import org.onosproject.yangutils.parser.impl.listeners.VersionListener;
+import org.onosproject.yangutils.parser.impl.listeners.WhenListener;
 
 import static org.onosproject.yangutils.utils.UtilConstants.UNSUPPORTED_YANG_CONSTRUCT;
 import static org.onosproject.yangutils.utils.UtilConstants.CURRENTLY_UNSUPPORTED;
@@ -473,22 +477,22 @@
 
     @Override
     public void enterFeatureStatement(GeneratedYangParser.FeatureStatementContext ctx) {
-        handleUnsupportedYangConstruct(YangConstructType.FEATURE_DATA, ctx, CURRENTLY_UNSUPPORTED);
+        FeatureListener.processFeatureEntry(this, ctx);
     }
 
     @Override
     public void exitFeatureStatement(GeneratedYangParser.FeatureStatementContext ctx) {
-        //TODO: to be implemented
+        FeatureListener.processFeatureExit(this, ctx);
     }
 
     @Override
     public void enterFeatureBody(GeneratedYangParser.FeatureBodyContext ctx) {
-        //TODO : to be implemented
+        // do nothing
     }
 
     @Override
     public void exitFeatureBody(GeneratedYangParser.FeatureBodyContext ctx) {
-        //TODO : to be implemented
+        // do nothing.
     }
 
     @Override
@@ -503,12 +507,12 @@
 
     @Override
     public void enterIfFeatureStatement(GeneratedYangParser.IfFeatureStatementContext ctx) {
-        // TODO: to be implemented
+        IfFeatureListener.processIfFeatureEntry(this, ctx);
     }
 
     @Override
     public void exitIfFeatureStatement(GeneratedYangParser.IfFeatureStatementContext ctx) {
-        // TODO: to be implemented
+        // do nothing.
     }
 
     @Override
@@ -813,12 +817,12 @@
 
     @Override
     public void enterMustStatement(GeneratedYangParser.MustStatementContext ctx) {
-        // TODO: to be implemented
+        MustListener.processMustEntry(this, ctx);
     }
 
     @Override
     public void exitMustStatement(GeneratedYangParser.MustStatementContext ctx) {
-        // TODO: to be implemented
+        MustListener.processMustExit(this, ctx);
     }
 
     @Override
@@ -1083,12 +1087,12 @@
 
     @Override
     public void enterWhenStatement(GeneratedYangParser.WhenStatementContext ctx) {
-        // TODO: to be implemented
+        WhenListener.processWhenEntry(this, ctx);
     }
 
     @Override
     public void exitWhenStatement(GeneratedYangParser.WhenStatementContext ctx) {
-        // TODO: to be implemented
+        WhenListener.processWhenExit(this, ctx);
     }
 
     @Override
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/FeatureListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/FeatureListener.java
new file mode 100644
index 0000000..6a70f31
--- /dev/null
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/FeatureListener.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2016-present 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.parser.impl.listeners;
+
+/*
+ * Reference: RFC6020 and YANG ANTLR Grammar
+ *
+ * ABNF grammar as per RFC6020
+ *  feature-stmt        = feature-keyword sep identifier-arg-str optsep
+ *                        (";" /
+ *                         "{" stmtsep
+ *                             ;; these stmts can appear in any order
+ *                             *(if-feature-stmt stmtsep)
+ *                             [status-stmt stmtsep]
+ *                             [description-stmt stmtsep]
+ *                             [reference-stmt stmtsep]
+ *                         "}")
+ *
+ *
+ *
+ * ANTLR grammar rule
+ * featureStatement : FEATURE_KEYWORD string (STMTEND | LEFT_CURLY_BRACE featureBody RIGHT_CURLY_BRACE);
+ */
+
+import org.onosproject.yangutils.datamodel.YangFeature;
+import org.onosproject.yangutils.datamodel.YangFeatureHolder;
+import org.onosproject.yangutils.datamodel.utils.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.utils.YangConstructType.FEATURE_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.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;
+
+/**
+ * Represents listener based call back function corresponding to the "feature"
+ * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ */
+public final class FeatureListener {
+
+    /**
+     * Creates a new feature listener.
+     */
+    private FeatureListener() {
+    }
+
+    /**
+     * Performs validation and updates the data model tree.It is called when parser receives
+     * an input matching the grammar rule (feature).
+     *
+     * @param listener listener's object
+     * @param ctx      context object of the grammar rule
+     */
+    public static void processFeatureEntry(TreeWalkListener listener,
+                                           GeneratedYangParser.FeatureStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, FEATURE_DATA, ctx.string().getText(), ENTRY);
+
+        String identifier = getValidIdentifier(ctx.string().getText(), FEATURE_DATA, ctx);
+
+        // Obtain the node of the stack.
+        Parsable tmpNode = listener.getParsedDataStack().peek();
+        if (tmpNode instanceof YangFeatureHolder) {
+            YangFeatureHolder featureHolder = (YangFeatureHolder) tmpNode;
+
+            YangFeature feature = new YangFeature();
+            feature.setName(identifier);
+
+            featureHolder.addFeatureList(feature);
+            listener.getParsedDataStack().push(feature);
+        } else {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, FEATURE_DATA,
+                    ctx.string().getText(), ENTRY));
+        }
+    }
+
+    /**
+     * Perform validations and updates the data model tree.It is called when parser exits from
+     * grammar rule(feature).
+     *
+     * @param listener listener's object
+     * @param ctx      context object of the grammar rule
+     */
+    public static void processFeatureExit(TreeWalkListener listener,
+                                          GeneratedYangParser.FeatureStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, FEATURE_DATA, ctx.string().getText(), EXIT);
+
+        if (listener.getParsedDataStack().peek() instanceof YangFeature) {
+            listener.getParsedDataStack().pop();
+        } else {
+            throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, FEATURE_DATA,
+                    ctx.string().getText(), EXIT));
+        }
+    }
+}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IfFeatureListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IfFeatureListener.java
new file mode 100644
index 0000000..29899de
--- /dev/null
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/IfFeatureListener.java
@@ -0,0 +1,143 @@
+/*
+ * Copyright 2016-present 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.parser.impl.listeners;
+
+/*
+ * Reference: RFC6020 and YANG ANTLR Grammar
+ *
+ * ABNF grammar as per RFC6020
+ *
+ * if-feature-stmt     = if-feature-keyword sep identifier-ref-arg-str
+ *                        optsep stmtend
+ *
+ * ANTLR grammar rule
+ * ifFeatureStatement : IF_FEATURE_KEYWORD string STMTEND;
+ */
+
+import org.onosproject.yangutils.datamodel.YangFeature;
+import org.onosproject.yangutils.datamodel.YangIfFeature;
+import org.onosproject.yangutils.datamodel.YangIfFeatureHolder;
+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.exceptions.DataModelException;
+import org.onosproject.yangutils.datamodel.utils.Parsable;
+import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl;
+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.utils.DataModelUtils.addResolutionInfo;
+import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.UNRESOLVED;
+import static org.onosproject.yangutils.datamodel.utils.YangConstructType.IF_FEATURE_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.INVALID_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;
+
+/**
+ * Represents listener based call back function corresponding to the "if-feature"
+ * rule defined in ANTLR grammar file for corresponding ABNF rule in RFC 6020.
+ */
+public final class IfFeatureListener {
+
+    /**
+     * Creates a new IfFeature listener.
+     */
+    private IfFeatureListener() {
+    }
+
+    /**
+     * Performs validation and updates the data model tree.It is called when parser receives
+     * an input matching the grammar rule (if-feature).
+     *
+     * @param listener listener's object
+     * @param ctx      context object of the grammar rule
+     */
+    public static void processIfFeatureEntry(TreeWalkListener listener,
+                                             GeneratedYangParser.IfFeatureStatementContext ctx) {
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, IF_FEATURE_DATA, ctx.string().getText(), ENTRY);
+
+        // Validate if-feature argument string
+        YangNodeIdentifier nodeIdentifier = getValidNodeIdentifier(ctx.string().getText(),
+                IF_FEATURE_DATA, ctx);
+
+        YangIfFeature ifFeature = new YangIfFeature();
+        ifFeature.setName(nodeIdentifier);
+        ifFeature.setResolvableStatus(UNRESOLVED);
+        YangIfFeatureHolder ifFeatureHolder;
+
+        // Obtain the node of the stack.
+        Parsable tmpNode = listener.getParsedDataStack().peek();
+        if (tmpNode instanceof YangIfFeatureHolder) {
+            ifFeatureHolder = (YangIfFeatureHolder) tmpNode;
+            ifFeatureHolder.addIfFeatureList(ifFeature);
+        } else {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IF_FEATURE_DATA,
+                    ctx.string().getText(), ENTRY));
+        }
+
+        // Add resolution information to the list
+        Parsable parentNode;
+        if (tmpNode instanceof YangLeafList || tmpNode instanceof YangLeaf
+                || tmpNode instanceof YangFeature) {
+            Parsable leafData = listener.getParsedDataStack().pop();
+            parentNode = listener.getParsedDataStack().peek();
+            listener.getParsedDataStack().push(leafData);
+        } else {
+            parentNode = tmpNode;
+        }
+
+        // Verify parent node of leaf
+        if (!(parentNode instanceof YangNode)) {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, IF_FEATURE_DATA,
+                    ctx.string().getText(), EXIT));
+        }
+
+        int errorLine = ctx.getStart().getLine();
+        int errorPosition = ctx.getStart().getCharPositionInLine();
+        YangResolutionInfoImpl resolutionInfo = new YangResolutionInfoImpl<YangIfFeature>(ifFeature,
+                (YangNode) parentNode, errorLine,
+                errorPosition);
+        addToResolutionList(resolutionInfo, ctx);
+    }
+
+    /**
+     * Add to resolution list.
+     *
+     * @param resolutionInfo resolution information.
+     * @param ctx            context object of the grammar rule
+     */
+    private static void addToResolutionList(YangResolutionInfo<YangIfFeature> resolutionInfo,
+                                            GeneratedYangParser.IfFeatureStatementContext ctx) {
+
+        try {
+            addResolutionInfo(resolutionInfo);
+        } catch (DataModelException e) {
+            throw new ParserException(constructExtendedListenerErrorMessage(UNHANDLED_PARSED_DATA,
+                    IF_FEATURE_DATA, ctx.string().getText(), EXIT, e.getMessage()));
+        }
+    }
+}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
index ef1af2d..05cfdb3 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListener.java
@@ -16,11 +16,13 @@
 
 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;
 import org.onosproject.yangutils.datamodel.YangRevision;
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
+import org.onosproject.yangutils.datamodel.utils.Parsable;
 import org.onosproject.yangutils.linker.exceptions.LinkerException;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -34,8 +36,8 @@
 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.getCurrentDateForRevision;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.setCurrentDateForRevision;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 import static org.onosproject.yangutils.translator.tojava.YangDataModelFactory.getYangModuleNode;
@@ -91,13 +93,6 @@
             yangModule.setVersion((byte) 1);
         }
 
-        if (ctx.moduleBody().revisionStatements().revisionStatement().isEmpty()) {
-            String currentDate = setCurrentDateForRevision();
-            YangRevision currentRevision = new YangRevision();
-            currentRevision.setRevDate(currentDate);
-            yangModule.setRevision(currentRevision);
-        }
-
         listener.getParsedDataStack().push(yangModule);
     }
 
@@ -113,12 +108,23 @@
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, MODULE_DATA, ctx.identifier().getText(), EXIT);
 
-        if (!(listener.getParsedDataStack().peek() instanceof YangModule)) {
+        Parsable tmpNode = listener.getParsedDataStack().peek();
+        if (!(tmpNode instanceof YangModule)) {
             throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MODULE_DATA,
                     ctx.identifier().getText(), EXIT));
         }
+
+        if (((YangModule) tmpNode).getRevision() == null) {
+            Date currentDate = getCurrentDateForRevision();
+            YangRevision currentRevision = new YangRevision();
+            currentRevision.setRevDate(currentDate);
+            ((YangModule) tmpNode).setRevision(currentRevision);
+        }
+
         try {
             ((YangReferenceResolver) listener.getParsedDataStack()
+                    .peek()).resolveSelfFileLinking(ResolvableType.YANG_IF_FEATURE);
+            ((YangReferenceResolver) listener.getParsedDataStack()
                     .peek()).resolveSelfFileLinking(ResolvableType.YANG_USES);
             ((YangReferenceResolver) listener.getParsedDataStack()
                     .peek()).resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MustListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MustListener.java
new file mode 100644
index 0000000..b6cbf20
--- /dev/null
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/MustListener.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2016-present 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.parser.impl.listeners;
+
+import org.onosproject.yangutils.datamodel.YangMust;
+import org.onosproject.yangutils.datamodel.YangMustHolder;
+import org.onosproject.yangutils.datamodel.utils.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.utils.YangConstructType.MUST_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.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.removeQuotesAndHandleConcat;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+
+/*
+ * Reference: RFC6020 and YANG ANTLR Grammar
+ *
+ * ABNF grammar as per RFC6020
+ *
+ *  must-stmt           = must-keyword sep string optsep
+ *                        (";" /
+ *                         "{" stmtsep
+ *                             ;; these stmts can appear in any order
+ *                             [error-message-stmt stmtsep]
+ *                             [error-app-tag-stmt stmtsep]
+ *                             [description-stmt stmtsep]
+ *                             [reference-stmt stmtsep]
+ *                          "}")
+ *
+ * ANTLR grammar rule
+ * mustStatement : MUST_KEYWORD string (STMTEND | LEFT_CURLY_BRACE commonStatements RIGHT_CURLY_BRACE);
+ */
+
+/**
+ * Represents listener based call back function corresponding to the
+ * "must" rule defined in ANTLR grammar file for corresponding ABNF rule
+ * in RFC 6020.
+ */
+public final class MustListener {
+
+    /**
+     * Creates a new must listener.
+     */
+    private MustListener() {
+    }
+
+    /**
+     * Perform validations and updates the data model tree.It is called when parser
+     * receives an input matching the grammar rule (must).
+     *
+     * @param listener listener's object
+     * @param ctx      context object of the grammar rule
+     */
+    public static void processMustEntry(TreeWalkListener listener,
+                                        GeneratedYangParser.MustStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, MUST_DATA, ctx.string().getText(), ENTRY);
+        String constraint = removeQuotesAndHandleConcat(ctx.string().getText());
+
+        // Obtain the node of the stack.
+        Parsable tmpNode = listener.getParsedDataStack().peek();
+        if (tmpNode instanceof YangMustHolder) {
+
+            YangMust must = new YangMust();
+            must.setConstraint(constraint);
+
+            YangMustHolder mustHolder = (YangMustHolder) tmpNode;
+            mustHolder.addMust(must);
+
+            listener.getParsedDataStack().push(must);
+        } else {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER, MUST_DATA,
+                    ctx.string().getText(), ENTRY));
+        }
+
+    }
+
+    /**
+     * Performs validation and updates the data model tree.It is called when parser
+     * exits from grammar rule (must).
+     *
+     * @param listener listener's object
+     * @param ctx      context object of the grammar rule
+     */
+    public static void processMustExit(TreeWalkListener listener,
+                                       GeneratedYangParser.MustStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, MUST_DATA, ctx.string().getText(), EXIT);
+
+        if (listener.getParsedDataStack().peek() instanceof YangMust) {
+            listener.getParsedDataStack().pop();
+        } else {
+            throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, MUST_DATA,
+                    ctx.string().getText(), EXIT));
+        }
+    }
+}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
index bb701a6..3ff67fe 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListener.java
@@ -16,6 +16,7 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import java.util.Date;
 import org.onosproject.yangutils.datamodel.YangImport;
 import org.onosproject.yangutils.datamodel.YangInclude;
 import org.onosproject.yangutils.datamodel.utils.Parsable;
@@ -28,8 +29,7 @@
 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_HOLDER;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.isDateValid;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidDateFromString;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 
 /*
@@ -87,13 +87,7 @@
         checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATE_DATA, ctx.dateArgumentString().getText(),
                 ENTRY);
 
-        String date = removeQuotesAndHandleConcat(ctx.dateArgumentString().getText());
-        if (!isDateValid(date)) {
-            ParserException parserException = new ParserException("YANG file error: Input date is not correct");
-            parserException.setLine(ctx.getStart().getLine());
-            parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
-            throw parserException;
-        }
+        Date date = getValidDateFromString(ctx.dateArgumentString().getText(), ctx);
 
         // Obtain the node of the stack.
         Parsable tmpNode = listener.getParsedDataStack().peek();
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
index 36d028a..cb633b8 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListener.java
@@ -16,6 +16,7 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import java.util.Date;
 import org.onosproject.yangutils.datamodel.YangModule;
 import org.onosproject.yangutils.datamodel.YangRevision;
 import org.onosproject.yangutils.datamodel.YangSubModule;
@@ -31,8 +32,7 @@
 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.isDateValid;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.removeQuotesAndHandleConcat;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidDateFromString;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 
 /*
@@ -88,20 +88,7 @@
         // Check for stack to be non empty.
         checkStackIsNotEmpty(listener, MISSING_HOLDER, REVISION_DATA, ctx.dateArgumentString().getText(), ENTRY);
 
-        // Validate for reverse chronological order of revision & for revision
-        // value.
-        if (!validateRevision(listener, ctx)) {
-            return;
-            // TODO to be implemented.
-        }
-
-        String date = removeQuotesAndHandleConcat(ctx.dateArgumentString().getText());
-        if (!isDateValid(date)) {
-            ParserException parserException = new ParserException("YANG file error: Input date is not correct");
-            parserException.setLine(ctx.getStart().getLine());
-            parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
-            throw parserException;
-        }
+        Date date = getValidDateFromString(ctx.dateArgumentString().getText(), ctx);
 
         YangRevision revisionNode = new YangRevision();
         revisionNode.setRevDate(date);
@@ -134,12 +121,26 @@
             switch (tmpNode.getYangConstructType()) {
                 case MODULE_DATA: {
                     YangModule module = (YangModule) tmpNode;
-                    module.setRevision((YangRevision) tmpRevisionNode);
+                    if (module.getRevision() != null) {
+                        Date curRevisionDate = module.getRevision().getRevDate();
+                        if (curRevisionDate.before(((YangRevision) tmpRevisionNode).getRevDate())) {
+                            module.setRevision((YangRevision) tmpRevisionNode);
+                        }
+                    } else {
+                        module.setRevision((YangRevision) tmpRevisionNode);
+                    }
                     break;
                 }
                 case SUB_MODULE_DATA: {
                     YangSubModule subModule = (YangSubModule) tmpNode;
-                    subModule.setRevision((YangRevision) tmpRevisionNode);
+                    if (subModule.getRevision() != null) {
+                        Date curRevisionDate = subModule.getRevision().getRevDate();
+                        if (curRevisionDate.before(((YangRevision) tmpRevisionNode).getRevDate())) {
+                            subModule.setRevision((YangRevision) tmpRevisionNode);
+                        }
+                    } else {
+                        subModule.setRevision((YangRevision) tmpRevisionNode);
+                    }
                     break;
                 }
                 default:
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
index 639906a..b2223b8 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListener.java
@@ -16,11 +16,13 @@
 
 package org.onosproject.yangutils.parser.impl.listeners;
 
+import java.util.Date;
 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.datamodel.utils.Parsable;
 import org.onosproject.yangutils.linker.exceptions.LinkerException;
 import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
 import org.onosproject.yangutils.parser.exceptions.ParserException;
@@ -34,8 +36,8 @@
 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.getCurrentDateForRevision;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.getValidIdentifier;
-import static org.onosproject.yangutils.parser.impl.parserutils.ListenerUtil.setCurrentDateForRevision;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsEmpty;
 import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
 import static org.onosproject.yangutils.translator.tojava.YangDataModelFactory.getYangSubModuleNode;
@@ -94,13 +96,6 @@
             yangSubModule.setVersion((byte) 1);
         }
 
-        if (ctx.submoduleBody().revisionStatements().revisionStatement().isEmpty()) {
-            String currentDate = setCurrentDateForRevision();
-            YangRevision currentRevision = new YangRevision();
-            currentRevision.setRevDate(currentDate);
-            yangSubModule.setRevision(currentRevision);
-        }
-
         listener.getParsedDataStack().push(yangSubModule);
     }
 
@@ -118,12 +113,23 @@
         checkStackIsNotEmpty(listener, MISSING_HOLDER, SUB_MODULE_DATA, ctx.identifier().getText(),
                 EXIT);
 
-        if (!(listener.getParsedDataStack().peek() instanceof YangSubModule)) {
+        Parsable tmpNode = listener.getParsedDataStack().peek();
+        if (!(tmpNode instanceof YangSubModule)) {
             throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, SUB_MODULE_DATA,
                     ctx.identifier().getText(), EXIT));
         }
+
+        if (((YangSubModule) tmpNode).getRevision() == null) {
+            Date currentDate = getCurrentDateForRevision();
+            YangRevision currentRevision = new YangRevision();
+            currentRevision.setRevDate(currentDate);
+            ((YangSubModule) tmpNode).setRevision(currentRevision);
+        }
+
         try {
             ((YangReferenceResolver) listener.getParsedDataStack().peek())
+                    .resolveSelfFileLinking(ResolvableType.YANG_IF_FEATURE);
+            ((YangReferenceResolver) listener.getParsedDataStack().peek())
                     .resolveSelfFileLinking(ResolvableType.YANG_USES);
             ((YangReferenceResolver) listener.getParsedDataStack().peek())
                     .resolveSelfFileLinking(ResolvableType.YANG_DERIVED_DATA_TYPE);
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/WhenListener.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/WhenListener.java
new file mode 100644
index 0000000..15092a1
--- /dev/null
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/listeners/WhenListener.java
@@ -0,0 +1,119 @@
+/*
+ * Copyright 2016-present 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.parser.impl.listeners;
+
+import org.onosproject.yangutils.datamodel.YangWhen;
+import org.onosproject.yangutils.datamodel.YangWhenHolder;
+import org.onosproject.yangutils.datamodel.utils.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.utils.YangConstructType.WHEN_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.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.removeQuotesAndHandleConcat;
+import static org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation.checkStackIsNotEmpty;
+
+/*
+ * Reference: RFC6020 and YANG ANTLR Grammar
+ *
+ * ABNF grammar as per RFC6020
+ *
+ *  when-stmt           = when-keyword sep string optsep
+ *                        (";" /
+ *                         "{" stmtsep
+ *                             ;; these stmts can appear in any order
+ *                             [description-stmt stmtsep]
+ *                             [reference-stmt stmtsep]
+ *                          "}")
+ *
+ * ANTLR grammar rule
+ * whenStatement : WHEN_KEYWORD string (STMTEND | LEFT_CURLY_BRACE ((descriptionStatement? referenceStatement?)
+ *       | (referenceStatement? descriptionStatement?)) RIGHT_CURLY_BRACE);
+ */
+
+/**
+ * Represents listener based call back function corresponding to the
+ * "when" rule defined in ANTLR grammar file for corresponding ABNF rule
+ * in RFC 6020.
+ */
+public final class WhenListener {
+
+    /**
+     * Creates a new when listener.
+     */
+    private WhenListener() {
+    }
+
+    /**
+     * Perform validations and updates the data model tree.It is called when parser
+     * receives an input matching the grammar rule (when).
+     *
+     * @param listener listener's object
+     * @param ctx      context object of the grammar rule
+     */
+    public static void processWhenEntry(TreeWalkListener listener,
+                                        GeneratedYangParser.WhenStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, WHEN_DATA, ctx.string().getText(), ENTRY);
+        String condition = removeQuotesAndHandleConcat(ctx.string().getText());
+
+        YangWhenHolder whenHolder;
+
+        // Obtain the node of the stack.
+        Parsable tmpNode = listener.getParsedDataStack().peek();
+        if (tmpNode instanceof YangWhenHolder) {
+            whenHolder = (YangWhenHolder) tmpNode;
+
+            YangWhen when = new YangWhen();
+            when.setCondition(condition);
+
+            whenHolder.setWhen(when);
+            listener.getParsedDataStack().push(when);
+        } else {
+            throw new ParserException(constructListenerErrorMessage(INVALID_HOLDER,
+                    WHEN_DATA, ctx.string().getText(), ENTRY));
+        }
+    }
+
+    /**
+     * Performs validation and updates the data model tree.It is called when parser
+     * exits from grammar rule (when).
+     *
+     * @param listener listener's object
+     * @param ctx      context object of the grammar rule
+     */
+    public static void processWhenExit(TreeWalkListener listener,
+                                       GeneratedYangParser.WhenStatementContext ctx) {
+
+        // Check for stack to be non empty.
+        checkStackIsNotEmpty(listener, MISSING_HOLDER, WHEN_DATA, ctx.string().getText(), EXIT);
+
+        if (listener.getParsedDataStack().peek() instanceof YangWhen) {
+            listener.getParsedDataStack().pop();
+        } else {
+            throw new ParserException(constructListenerErrorMessage(MISSING_CURRENT_HOLDER, WHEN_DATA,
+                    ctx.string().getText(), EXIT));
+        }
+    }
+}
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java
index d05c8d0..e2097fc 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/parser/impl/parserutils/ListenerUtil.java
@@ -18,7 +18,7 @@
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
+import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.regex.Pattern;
@@ -30,20 +30,18 @@
 import org.onosproject.yangutils.parser.exceptions.ParserException;
 
 import static org.onosproject.yangutils.utils.UtilConstants.ADD;
-import static org.onosproject.yangutils.utils.UtilConstants.SPACE;
-import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
-import static org.onosproject.yangutils.utils.UtilConstants.COLON;
 import static org.onosproject.yangutils.utils.UtilConstants.CARET;
+import static org.onosproject.yangutils.utils.UtilConstants.COLON;
 import static org.onosproject.yangutils.utils.UtilConstants.CURRENTLY_UNSUPPORTED;
-import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
-import static org.onosproject.yangutils.utils.UtilConstants.HYPHEN;
 import static org.onosproject.yangutils.utils.UtilConstants.EMPTY_STRING;
-import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
 import static org.onosproject.yangutils.utils.UtilConstants.FALSE;
-import static org.onosproject.yangutils.utils.UtilConstants.YANG_FILE_ERROR;
 import static org.onosproject.yangutils.utils.UtilConstants.IDENTITYREF;
-import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF;
 import static org.onosproject.yangutils.utils.UtilConstants.INSTANCE_IDENTIFIER;
+import static org.onosproject.yangutils.utils.UtilConstants.LEAFREF;
+import static org.onosproject.yangutils.utils.UtilConstants.QUOTES;
+import static org.onosproject.yangutils.utils.UtilConstants.SLASH;
+import static org.onosproject.yangutils.utils.UtilConstants.TRUE;
+import static org.onosproject.yangutils.utils.UtilConstants.YANG_FILE_ERROR;
 
 /**
  * Represents an utility for listener.
@@ -256,17 +254,24 @@
     }
 
     /**
-     * Sets current date and makes it in usable format for revision.
+     * Returns current date and makes it in usable format for revision.
      *
      * @return usable current date format for revision
      */
-    public static String setCurrentDateForRevision() {
+    public static Date getCurrentDateForRevision() {
 
-        Calendar date = Calendar.getInstance();
         SimpleDateFormat dateFormat = new SimpleDateFormat(DATE_FORMAT);
-        String dateForRevision = dateFormat.format(date.getTime()).replaceAll(SLASH, HYPHEN).replaceAll(SPACE,
-                EMPTY_STRING);
-        return dateForRevision;
+
+        Date date = new Date();
+        String dateInString = dateFormat.format(date);
+        try {
+            //if not valid, it will throw ParseException
+            Date now = dateFormat.parse(dateInString);
+            return date;
+        } catch (ParseException e) {
+            ParserException parserException = new ParserException("YANG file error: Input date is not correct");
+            throw parserException;
+        }
     }
 
     /**
@@ -373,4 +378,35 @@
         parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
         throw parserException;
     }
+
+    /**
+     * Returns date and makes it in usable format for revision.
+     *
+     * @param dateInString date argument string from yang file
+     * @param ctx          yang construct's context to get the line number and character position
+     * @return date format for revision
+     */
+    public static Date getValidDateFromString(String dateInString, ParserRuleContext ctx) {
+        String dateArgument = removeQuotesAndHandleConcat(dateInString);
+        if (dateArgument == null || !dateArgument.matches(DATE_PATTERN)) {
+            ParserException parserException = new ParserException("YANG file error: Input date is not correct");
+            parserException.setLine(ctx.getStart().getLine());
+            parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
+            throw parserException;
+        }
+
+        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+        sdf.setLenient(false);
+
+        try {
+            //if not valid, it will throw ParseException
+            Date date = sdf.parse(dateArgument);
+            return date;
+        } catch (ParseException e) {
+            ParserException parserException = new ParserException("YANG file error: Input date is not correct");
+            parserException.setLine(ctx.getStart().getLine());
+            parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
+            throw parserException;
+        }
+    }
 }
\ No newline at end of file
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
index c9b2765..8c938ed 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/translator/tojava/utils/JavaIdentifierSyntax.java
@@ -18,7 +18,9 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import org.onosproject.yangutils.datamodel.YangNode;
 import org.onosproject.yangutils.translator.exception.TranslatorException;
@@ -59,6 +61,7 @@
     private static final int INDEX_TWO = 2;
     private static final int VALUE_CHECK = 10;
     private static final String ZERO = "0";
+    private static final String DATE_FORMAT = "yyyy-MM-dd";
 
     /**
      * Create instance of java identifier syntax.
@@ -75,7 +78,7 @@
      * @param conflictResolver object of YANG to java naming conflict util
      * @return the root package string
      */
-    public static String getRootPackage(byte version, String nameSpace, String revision,
+    public static String getRootPackage(byte version, String nameSpace, Date revision,
                                         YangToJavaNamingConflictUtil conflictResolver) {
 
         String pkg;
@@ -125,30 +128,23 @@
      *
      * @param date YANG module revision
      * @return revision string
-     * @throws TranslatorException when date is invalid.
      */
-    private static String getYangRevisionStr(String date) throws TranslatorException {
-
-        String[] revisionArr = date.split(HYPHEN);
+    private static String getYangRevisionStr(Date date) {
+        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
+        String dateInString = sdf.format(date);
+        String[] revisionArr = dateInString.split(HYPHEN);
 
         String rev = REVISION_PREFIX;
         rev = rev + revisionArr[INDEX_ZERO];
 
-        if (Integer.parseInt(revisionArr[INDEX_ONE]) <= MAX_MONTHS
-                && Integer.parseInt(revisionArr[INDEX_TWO]) <= MAX_DAYS) {
-            for (int i = INDEX_ONE; i < revisionArr.length; i++) {
-
-                Integer val = Integer.parseInt(revisionArr[i]);
-                if (val < VALUE_CHECK) {
-                    rev = rev + ZERO;
-                }
-                rev = rev + val;
+        for (int i = INDEX_ONE; i < revisionArr.length; i++) {
+            Integer val = Integer.parseInt(revisionArr[i]);
+            if (val < VALUE_CHECK) {
+                rev = rev + ZERO;
             }
-
-            return rev;
-        } else {
-            throw new TranslatorException("Date in revision is not proper: " + date);
+            rev = rev + val;
         }
+        return rev;
     }
 
     /**
diff --git a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
index 37b8992..f4999b6 100644
--- a/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
+++ b/utils/yangutils/plugin/src/main/java/org/onosproject/yangutils/utils/UtilConstants.java
@@ -1140,6 +1140,12 @@
             + "grouping for given uses";
 
     /**
+     * Static attribute for grouping linker error information.
+     */
+    public static final String FEATURE_LINKER_ERROR = "YANG file error: Unable to find feature "
+            + "for given if-feature";
+
+    /**
      * Static attribute for reference.
      */
     public static final String REFERENCE = "Reference";