[ONOS-4798] Error Message implementation for YANG utils

Change-Id: Idb13e851258754773f8f447ace69a9393c7c1b3d
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorHolder.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorHolder.java
new file mode 100644
index 0000000..484aec1
--- /dev/null
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorHolder.java
@@ -0,0 +1,38 @@
+/*
+ * 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.datamodel;
+
+/**
+ * Represents data model node to maintain YANG app error message information.
+ */
+public interface YangAppErrorHolder {
+
+    /**
+     * Sets the application's error information.
+     *
+     * @param yangAppErrorInfo the application's error information
+     */
+    void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo);
+
+    /**
+     * Returns application's error information.
+     *
+     * @return application's error information
+     */
+    YangAppErrorInfo getAppErrorInfo();
+
+}
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorInfo.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorInfo.java
index 671aa08..213dccf 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorInfo.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangAppErrorInfo.java
@@ -1,48 +1,149 @@
-/*Copyright 2016.year Open Networking Laboratory
+/*
+ * 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.
+ */
 
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-    http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.*/
 package org.onosproject.yangutils.datamodel;
 
+import java.io.Serializable;
+
 /**
- * Abstraction of error message and application info processing.
+ * Represents data model to maintain yang app error information.
  */
-public interface YangAppErrorInfo {
+public class YangAppErrorInfo implements Serializable {
+
+    private static final long serialVersionUID = 807201693L;
 
     /**
-     * Returns the application's error message for data error.
-     *
-     * @return application's error message for data error.
+     * Application's error message, to be used for data error.
      */
-    String getGetErrorMessage();
+    private String errorMessage;
 
     /**
-     * Sets the application's error message for data error.
-     *
-     * @param errorMessage application's error message for data error.
+     * Error tag, to be filled in data validation error response.
      */
-    void setErrorMessage(String errorMessage);
+    private String errorTag;
 
     /**
-     * Returns the application's error tag for data error.
-     *
-     * @return application's error tag for data error.
+     * Application's error tag, to be filled in data validation error response.
      */
-    String getGetErrorAppTag();
+    private String errorAppTag;
 
     /**
-     * Sets the application's error tag for data error.
-     *
-     * @param errorMessage application's error tag for data error.
+     * Application's error path, to be filled in data validation error response.
      */
-    void setErrorAppTag(String errorMessage);
+    private String errorAppPath;
+
+    /**
+     * Application's error info, to be filled in data validation error response.
+     */
+    private String errorAppInfo;
+
+    /**
+     * Creates a YANG app error info object.
+     */
+    @SuppressWarnings("unused")
+    public YangAppErrorInfo() {
+    }
+
+    /**
+     * Returns application's error message, to be used for data error.
+     *
+     * @return Application's error message, to be used for data error
+     */
+    public String getGetErrorMessage() {
+        return errorMessage;
+    }
+
+    /**
+     * Sets Application's error message, to be used for data error.
+     *
+     * @param errMsg Application's error message, to be used for data error
+     */
+    public void setErrorMessage(String errMsg) {
+        errorMessage = errMsg;
+    }
+
+    /**
+     * Returns error tag, to be used for data error.
+     *
+     * @return error tag, to be used for data error
+     */
+    public String getGetErrorTag() {
+        return errorTag;
+    }
+
+    /**
+     * Sets error tag, to be used for data error.
+     *
+     * @param errTag error tag, to be used for data error
+     */
+    public void setErrorTag(String errTag) {
+        errorTag = errTag;
+    }
+
+    /**
+     * Returns application's error tag, to be used for data error.
+     *
+     * @return application's error tag, to be used for data error
+     */
+    public String getGetErrorAppTag() {
+        return errorAppTag;
+    }
+
+    /**
+     * Sets application's error tag, to be used for data error.
+     *
+     * @param errTag application's error tag, to be used for data error
+     */
+    public void setErrorAppTag(String errTag) {
+        errorAppTag = errTag;
+    }
+
+    /**
+     * Returns application's error path, to be used for data error.
+     *
+     * @return application's error path, to be used for data error
+     */
+    public String getGetErrorAppPath() {
+        return errorAppPath;
+    }
+
+    /**
+     * Sets application's error path, to be used for data error.
+     *
+     * @param errPath application's error path, to be used for data error
+     */
+    public void setErrorAppPath(String errPath) {
+        errorAppPath = errPath;
+    }
+
+    /**
+     * Returns application's error info, to be used for data error.
+     *
+     * @return application's error info, to be used for data error
+     */
+    public String getGetErrorAppInfo() {
+        return errorAppInfo;
+    }
+
+    /**
+     * Sets application's error info, to be used for data error.
+     *
+     * @param errInfo application's error info, to be used for data error
+     */
+    public void setErrorAppInfo(String errInfo) {
+        errorAppInfo = errInfo;
+    }
 }
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
index 5e78d55..b7bdf08 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangChoice.java
@@ -23,6 +23,9 @@
 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
 
 import static org.onosproject.yangutils.datamodel.utils.YangConstructType.CHOICE_DATA;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.DATA_MISSING_ERROR_TAG;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.ERROR_PATH_MISSING_CHOICE;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.MISSING_CHOICE_ERROR_APP_TAG;
 
 /*-
  * Reference RFC 6020.
@@ -65,7 +68,7 @@
  */
 public class YangChoice extends YangNode
         implements YangCommonInfo, Parsable, CollisionDetector, YangAugmentableNode,
-        YangWhenHolder, YangIfFeatureHolder {
+        YangWhenHolder, YangIfFeatureHolder, YangAppErrorHolder {
 
     private static final long serialVersionUID = 806201604L;
 
@@ -160,10 +163,19 @@
     private List<YangAugmentedInfo> yangAugmentedInfo = new ArrayList<>();
 
     /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
      * Create a choice node.
      */
     public YangChoice() {
         super(YangNodeType.CHOICE_NODE);
+        yangAppErrorInfo = new YangAppErrorInfo();
+        yangAppErrorInfo.setErrorTag(DATA_MISSING_ERROR_TAG);
+        yangAppErrorInfo.setErrorAppTag(MISSING_CHOICE_ERROR_APP_TAG);
+        yangAppErrorInfo.setErrorAppPath(ERROR_PATH_MISSING_CHOICE);
     }
 
     /**
@@ -435,4 +447,15 @@
     public List<YangAugmentedInfo> getAugmentedInfoList() {
         return yangAugmentedInfo;
     }
+
+    @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
+
 }
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
index 11e55db..cbb2038 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafList.java
@@ -87,7 +87,7 @@
      *
      * If no "max-elements" statement is present, it defaults to "unbounded".
      */
-    private int maxElelements = Integer.MAX_VALUE;
+    private YangMaxElement maxElement;
 
     /**
      * Reference:RFC 6020.
@@ -107,7 +107,7 @@
      *
      * o Otherwise, it is enforced if the ancestor node exists.
      */
-    private int minElements = 0;
+    private YangMinElement minElements;
 
     /**
      * The textual reference to this leaf-list.
@@ -153,6 +153,8 @@
      * Creates a YANG leaf-list.
      */
     public YangLeafList() {
+        setMinElements(new YangMinElement());
+        setMaxElements(new YangMaxElement());
     }
 
     /**
@@ -232,38 +234,38 @@
     }
 
     /**
-     * Returns the max elements no.
+     * Returns the maximum elements number.
      *
-     * @return the max elements no
+     * @return the maximum elements number
      */
-    public int getMaxElelements() {
-        return maxElelements;
+    public YangMaxElement getMaxElements() {
+        return maxElement;
     }
 
     /**
-     * Sets the max elements no.
+     * Sets the maximum elements number.
      *
-     * @param maxElelements max elements no
+     * @param maxElement maximum elements number
      */
-    public void setMaxElelements(int maxElelements) {
-        this.maxElelements = maxElelements;
+    public void setMaxElements(YangMaxElement maxElement) {
+        this.maxElement = maxElement;
     }
 
     /**
-     * Returns the min elements no.
+     * Returns the minimum elements number.
      *
-     * @return the min elements no
+     * @return the minimum elements number
      */
-    public int getMinElements() {
+    public YangMinElement getMinElements() {
         return minElements;
     }
 
     /**
-     * Sets the min elements no.
+     * Sets the minimum elements number.
      *
-     * @param minElements the min elements no
+     * @param minElements the minimum elements number
      */
-    public void setMinElements(int minElements) {
+    public void setMinElements(YangMinElement minElements) {
         this.minElements = minElements;
     }
 
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafRef.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafRef.java
index 0c3a98f..4973303 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafRef.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLeafRef.java
@@ -29,6 +29,9 @@
 
 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.INTRA_FILE_RESOLVED;
 import static org.onosproject.yangutils.datamodel.utils.ResolvableStatus.RESOLVED;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.DATA_MISSING_ERROR_TAG;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.ERROR_PATH_LEAFREF_LEAF;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.INSTANCE_REQUIRED_ERROR_APP_TAG;
 
 /*
  * Reference:RFC 6020.
@@ -44,7 +47,7 @@
  * @param <T> YANG leafref info
  */
 public class YangLeafRef<T> implements Parsable, Resolvable, Serializable, YangIfFeatureHolder,
-        YangXPathResolver {
+        YangXPathResolver, YangAppErrorHolder {
 
     private static final long serialVersionUID = 286201644L;
 
@@ -97,6 +100,21 @@
     private List<YangIfFeature> ifFeatureList;
 
     /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
+     * Creates a YANG leaf ref.
+     */
+    public YangLeafRef() {
+        yangAppErrorInfo = new YangAppErrorInfo();
+        yangAppErrorInfo.setErrorTag(DATA_MISSING_ERROR_TAG);
+        yangAppErrorInfo.setErrorAppTag(INSTANCE_REQUIRED_ERROR_APP_TAG);
+        yangAppErrorInfo.setErrorAppPath(ERROR_PATH_LEAFREF_LEAF);
+    }
+
+    /**
      * Returns the status of the require instance in leafref.
      *
      * @return status of the require instance
@@ -266,6 +284,16 @@
     }
 
     @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
+
+    @Override
     public void resolve() throws DataModelException {
 
         if (getReferredLeafOrLeafList() == null) {
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java
index 9157801..43780a6 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangLengthRestriction.java
@@ -33,7 +33,7 @@
 /**
  * Represents the restriction for length data type.
  */
-public class YangLengthRestriction implements YangDesc, YangReference, YangAppErrorInfo, Parsable, Serializable {
+public class YangLengthRestriction implements YangDesc, YangReference, Parsable, Serializable, YangAppErrorHolder {
 
     /*-
      * Reference RFC 6020.
@@ -84,21 +84,16 @@
     private String reference;
 
     /**
-     * Application's error message, to be used for data error.
-     */
-    private String errorMessage;
-
-    /**
-     * Application's error tag, to be filled in data validation error response.
-     */
-    private String errorAppTag;
-
-    /**
      * Textual description.
      */
     private String description;
 
     /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
      * Creates a YANG length restriction object.
      */
     public YangLengthRestriction() {
@@ -164,47 +159,6 @@
 
     }
 
-    /**
-     * Returns application's error message, to be used for data error.
-     *
-     * @return Application's error message, to be used for data error
-     */
-    @Override
-    public String getGetErrorMessage() {
-        return errorMessage;
-    }
-
-    /**
-     * Sets Application's error message, to be used for data error.
-     *
-     * @param errMsg Application's error message, to be used for data error
-     */
-    @Override
-    public void setErrorMessage(String errMsg) {
-        errorMessage = errMsg;
-
-    }
-
-    /**
-     * Returns application's error tag, to be used for data error.
-     *
-     * @return application's error tag, to be used for data error
-     */
-    @Override
-    public String getGetErrorAppTag() {
-        return errorAppTag;
-    }
-
-    /**
-     * Sets application's error tag, to be used for data error.
-     *
-     * @param errTag application's error tag, to be used for data error.
-     */
-    @Override
-    public void setErrorAppTag(String errTag) {
-        errorAppTag = errTag;
-    }
-
     @Override
     public YangConstructType getYangConstructType() {
         return YangConstructType.PATTERN_DATA;
@@ -219,4 +173,24 @@
     public void validateDataOnExit() throws DataModelException {
         // TODO: implement the method.
     }
+
+    /**
+     * Sets the application's error information.
+     *
+     * @param yangAppErrorInfo the application's error information
+     */
+    @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    /**
+     * Returns application's error information.
+     *
+     * @return application's error information
+     */
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
 }
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
index 2d28525..d5eafb1 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangList.java
@@ -140,7 +140,7 @@
      *
      * If no "max-elements" statement is present, it defaults to "unbounded".
      */
-    private int maxElements = Integer.MAX_VALUE;
+    private YangMaxElement maxElements;
 
     /**
      * Reference RFC 6020.
@@ -160,7 +160,7 @@
      *
      * o Otherwise, it is enforced if the ancestor node exists.
      */
-    private int minElements = 0;
+    private YangMinElement minElements;
 
     /**
      * reference.
@@ -381,7 +381,7 @@
      *
      * @return the max elements
      */
-    public int getMaxElements() {
+    public YangMaxElement getMaxElements() {
         return maxElements;
     }
 
@@ -390,8 +390,8 @@
      *
      * @param max the max elements
      */
-    public void setMaxElements(int max) {
-        maxElements = max;
+    public void setMaxElements(YangMaxElement max) {
+        this.maxElements = max;
     }
 
     /**
@@ -399,7 +399,7 @@
      *
      * @return the minimum elements
      */
-    public int getMinElements() {
+    public YangMinElement getMinElements() {
         return minElements;
     }
 
@@ -408,7 +408,7 @@
      *
      * @param minElements the minimum elements
      */
-    public void setMinElements(int minElements) {
+    public void setMinElements(YangMinElement minElements) {
         this.minElements = minElements;
     }
 
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMaxElement.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMaxElement.java
new file mode 100644
index 0000000..6ec7f47
--- /dev/null
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMaxElement.java
@@ -0,0 +1,84 @@
+/*
+ * 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.datamodel;
+
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.OPERATION_FAILED_ERROR_TAG;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.TOO_MANY_ELEMENTS_ERROR_APP_TAG;
+
+import java.io.Serializable;
+
+/**
+ * Represents max element data represented in YANG.
+ */
+public class YangMaxElement implements YangAppErrorHolder, Serializable {
+
+    private static final long serialVersionUID = 807201694L;
+
+    /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
+     * Reference:RFC 6020.
+     *
+     * The "max-elements" statement, which is optional, takes as an argument a
+     * positive integer or the string "unbounded", which puts a constraint on
+     * valid list entries. A valid leaf-list or list always has at most
+     * max-elements entries.
+     *
+     * If no "max-elements" statement is present, it defaults to "unbounded".
+     */
+    private int maxElement = Integer.MAX_VALUE;
+
+    /**
+     * Creates a YANG maximum element.
+     */
+    public YangMaxElement() {
+        YangAppErrorInfo yangAppErrorInfo = new YangAppErrorInfo();
+        yangAppErrorInfo.setErrorTag(OPERATION_FAILED_ERROR_TAG);
+        yangAppErrorInfo.setErrorAppTag(TOO_MANY_ELEMENTS_ERROR_APP_TAG);
+    }
+
+    /**
+     * Returns the maximum element value.
+     *
+     * @return the maximum element value
+     */
+    public int getMaxElement() {
+        return maxElement;
+    }
+
+    /**
+     * Sets the maximum element value.
+     *
+     * @param maxElement the maximum element value
+     */
+    public void setMaxElement(int maxElement) {
+        this.maxElement = maxElement;
+    }
+
+    @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
+}
\ No newline at end of file
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMinElement.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMinElement.java
new file mode 100644
index 0000000..4eab3a8
--- /dev/null
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMinElement.java
@@ -0,0 +1,92 @@
+/*
+ * 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.datamodel;
+
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.OPERATION_FAILED_ERROR_TAG;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.TOO_FEW_ELEMENTS_ERROR_APP_TAG;
+
+import java.io.Serializable;
+
+/**
+ * Represents minimum element data represented in YANG.
+ */
+public class YangMinElement implements YangAppErrorHolder, Serializable {
+
+    private static final long serialVersionUID = 807201695L;
+
+    /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
+     * Reference:RFC 6020.
+     *
+     * The "min-elements" statement, which is optional, takes as an argument a
+     * non-negative integer that puts a constraint on valid list entries. A
+     * valid leaf-list or list MUST have at least min-elements entries.
+     *
+     * If no "min-elements" statement is present, it defaults to zero.
+     *
+     * The behavior of the constraint depends on the type of the leaf-list's or
+     * list's closest ancestor node in the schema tree that is not a non-
+     * presence container:
+     *
+     * If this ancestor is a case node, the constraint is enforced if any
+     * other node from the case exists.
+     *
+     * Otherwise, it is enforced if the ancestor node exists.
+     */
+    private int minElement = 0;
+
+    /**
+     * Creates a YANG minimum element.
+     */
+    public YangMinElement() {
+        YangAppErrorInfo yangAppErrorInfo = new YangAppErrorInfo();
+        yangAppErrorInfo.setErrorTag(OPERATION_FAILED_ERROR_TAG);
+        yangAppErrorInfo.setErrorAppTag(TOO_FEW_ELEMENTS_ERROR_APP_TAG);
+    }
+
+    /**
+     * Returns the minimum element value.
+     *
+     * @return the minimum element value
+     */
+    public int getMinElement() {
+        return minElement;
+    }
+
+    /**
+     * Sets the minimum element value.
+     *
+     * @param minElement the minimum element value
+     */
+    public void setMinElement(int minElement) {
+        this.minElement = minElement;
+    }
+
+    @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
+}
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
index c579003..62f6c9e 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangMust.java
@@ -20,6 +20,8 @@
 import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
 import org.onosproject.yangutils.datamodel.utils.Parsable;
 import org.onosproject.yangutils.datamodel.utils.YangConstructType;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.OPERATION_FAILED_ERROR_TAG;
+import static org.onosproject.yangutils.datamodel.utils.YangErrMsgConstants.MUST_VIOLATION_ERROR_APP_TAG;
 
 /*-
  * The "must" statement, which is optional, takes as an argument a string that
@@ -48,7 +50,7 @@
 /**
  * Represents information defined in YANG must.
  */
-public class YangMust implements YangDesc, YangReference, Parsable, Serializable {
+public class YangMust implements YangDesc, YangReference, Parsable, Serializable, YangAppErrorHolder {
 
     private static final long serialVersionUID = 806201646L;
 
@@ -68,9 +70,17 @@
     private String reference;
 
     /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
      * Creates a YANG must restriction.
      */
     public YangMust() {
+        yangAppErrorInfo = new YangAppErrorInfo();
+        yangAppErrorInfo.setErrorTag(OPERATION_FAILED_ERROR_TAG);
+        yangAppErrorInfo.setErrorAppTag(MUST_VIOLATION_ERROR_APP_TAG);
     }
 
     /**
@@ -160,4 +170,14 @@
     public void validateDataOnExit() throws DataModelException {
         // TODO auto-generated method stub, to be implemented by parser
     }
+
+    @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
 }
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangPatternRestriction.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangPatternRestriction.java
index 939b732..9e5d8ef 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangPatternRestriction.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangPatternRestriction.java
@@ -52,7 +52,7 @@
  * Represents pattern restriction information. The regular expression restriction on string
  * data type.
  */
-public class YangPatternRestriction implements Serializable {
+public class YangPatternRestriction implements Serializable, YangAppErrorHolder {
 
     private static final long serialVersionUID = 806201649L;
 
@@ -62,6 +62,11 @@
     private List<String> patternList;
 
     /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
      * Creates a YANG pattern restriction object.
      */
     public YangPatternRestriction() {
@@ -94,4 +99,14 @@
     public void addPattern(String newPattern) {
         getPatternList().add(newPattern);
     }
+
+    @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
 }
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
index b49dda6..ae9b68e 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangRangeRestriction.java
@@ -59,7 +59,7 @@
  * @param <T> range type (data type)
  */
 public class YangRangeRestriction<T extends YangBuiltInDataTypeInfo<T>>
-        implements YangDesc, YangReference, YangAppErrorInfo, Parsable, Serializable {
+        implements YangDesc, YangReference, Parsable, Serializable, YangAppErrorHolder {
 
     private static final long serialVersionUID = 8062016051L;
 
@@ -75,21 +75,16 @@
     private String reference;
 
     /**
-     * Application's error message, to be used for data error.
-     */
-    private String errorMessage;
-
-    /**
-     * Application's error tag, to be filled in data validation error response.
-     */
-    private String errorAppTag;
-
-    /**
      * Textual description.
      */
     private String description;
 
     /**
+     * YANG application error information.
+     */
+    private YangAppErrorInfo yangAppErrorInfo;
+
+    /**
      * Creates YANG range restriction object.
      */
     public YangRangeRestriction() {
@@ -278,47 +273,6 @@
 
     }
 
-    /**
-     * Returns application's error message, to be used for data error.
-     *
-     * @return Application's error message, to be used for data error
-     */
-    @Override
-    public String getGetErrorMessage() {
-        return errorMessage;
-    }
-
-    /**
-     * Sets Application's error message, to be used for data error.
-     *
-     * @param errMsg Application's error message, to be used for data error
-     */
-    @Override
-    public void setErrorMessage(String errMsg) {
-        errorMessage = errMsg;
-
-    }
-
-    /**
-     * Returns application's error tag, to be used for data error.
-     *
-     * @return application's error tag, to be used for data error
-     */
-    @Override
-    public String getGetErrorAppTag() {
-        return errorAppTag;
-    }
-
-    /**
-     * Sets application's error tag, to be used for data error.
-     *
-     * @param errTag application's error tag, to be used for data error.
-     */
-    @Override
-    public void setErrorAppTag(String errTag) {
-        errorAppTag = errTag;
-    }
-
     @Override
     public YangConstructType getYangConstructType() {
         return YangConstructType.RANGE_DATA;
@@ -333,4 +287,14 @@
     public void validateDataOnExit() throws DataModelException {
         // TODO: implement the method.
     }
+
+    @Override
+    public void setAppErrorInfo(YangAppErrorInfo yangAppErrorInfo) {
+        this.yangAppErrorInfo = yangAppErrorInfo;
+    }
+
+    @Override
+    public YangAppErrorInfo getAppErrorInfo() {
+        return yangAppErrorInfo;
+    }
 }
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
index ce626ed..b52a70e 100644
--- a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/YangStringRestriction.java
@@ -33,7 +33,7 @@
 /**
  * Represents the restriction for string data type.
  */
-public class YangStringRestriction implements YangDesc, YangReference, YangAppErrorInfo, Parsable, Serializable {
+public class YangStringRestriction implements YangDesc, YangReference, Parsable, Serializable {
 
     /*-
      * Reference RFC 6020.
@@ -89,16 +89,6 @@
     private String reference;
 
     /**
-     * Application's error message, to be used for data error.
-     */
-    private String errorMessage;
-
-    /**
-     * Application's error tag, to be filled in data validation error response.
-     */
-    private String errorAppTag;
-
-    /**
      * Textual description.
      */
     private String description;
@@ -198,47 +188,6 @@
 
     }
 
-    /**
-     * Returns application's error message, to be used for data error.
-     *
-     * @return Application's error message, to be used for data error
-     */
-    @Override
-    public String getGetErrorMessage() {
-        return errorMessage;
-    }
-
-    /**
-     * Sets Application's error message, to be used for data error.
-     *
-     * @param errMsg Application's error message, to be used for data error
-     */
-    @Override
-    public void setErrorMessage(String errMsg) {
-        errorMessage = errMsg;
-
-    }
-
-    /**
-     * Returns application's error tag, to be used for data error.
-     *
-     * @return application's error tag, to be used for data error
-     */
-    @Override
-    public String getGetErrorAppTag() {
-        return errorAppTag;
-    }
-
-    /**
-     * Sets application's error tag, to be used for data error.
-     *
-     * @param errTag application's error tag, to be used for data error.
-     */
-    @Override
-    public void setErrorAppTag(String errTag) {
-        errorAppTag = errTag;
-    }
-
     @Override
     public YangConstructType getYangConstructType() {
         return YangConstructType.PATTERN_DATA;
diff --git a/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/YangErrMsgConstants.java b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/YangErrMsgConstants.java
new file mode 100644
index 0000000..4468d9b
--- /dev/null
+++ b/utils/yangutils/datamodel/src/main/java/org/onosproject/yangutils/datamodel/utils/YangErrMsgConstants.java
@@ -0,0 +1,94 @@
+/*
+ * 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.datamodel.utils;
+
+/**
+ * Represents default YANG error message types.
+ */
+public final class YangErrMsgConstants {
+
+    /**
+     * Static attribute for operation failed error tag.
+     */
+    public static final String OPERATION_FAILED_ERROR_TAG = "operation-failed";
+
+    /**
+     * Static attribute for data missing error tag.
+     */
+    public static final String DATA_MISSING_ERROR_TAG = "data-missing";
+
+    /**
+     * Static attribute for bad attribute error tag.
+     */
+    public static final String BAD_ATTRIBUTE_ERROR_TAG = "bad-attribute";
+
+    /**
+     * Static attribute for data not unique error app tag.
+     */
+    public static final String DATA_NOT_UNIQUE_ERROR_APP_TAG = "data-not-unique";
+
+    /**
+     * Static attribute for too many elements error app tag.
+     */
+    public static final String TOO_MANY_ELEMENTS_ERROR_APP_TAG = "too-many-elements";
+
+    /**
+     * Static attribute for too few elements error app tag.
+     */
+    public static final String TOO_FEW_ELEMENTS_ERROR_APP_TAG = "too-few-elements";
+
+    /**
+     * Static attribute for must violation error app tag.
+     */
+    public static final String MUST_VIOLATION_ERROR_APP_TAG = "must-violation";
+
+    /**
+     * Static attribute for instance required error app tag.
+     */
+    public static final String INSTANCE_REQUIRED_ERROR_APP_TAG = "instance-required";
+
+    /**
+     * Static attribute for missing choice error app tag.
+     */
+    public static final String MISSING_CHOICE_ERROR_APP_TAG = "missing-choice";
+
+    /**
+     * Static attribute for missing instance error app tag.
+     */
+    public static final String MISSING_INSTANCE_ERROR_APP_TAG = "missing-instance";
+
+    /**
+     * TODO: Static attribute for error path to the instance-identifier leaf.
+     */
+    public static final String ERROR_PATH_INSTANCE_IDENTIFIER_LEAF = "Path to the instance-identifier leaf.";
+
+    /**
+     * Static attribute for error path to the missing choice.
+     */
+    public static final String ERROR_PATH_MISSING_CHOICE = "Path to the element with the missing choice.";
+
+    /**
+     * Static attribute for error path to the leafref leaf.
+     */
+    public static final String ERROR_PATH_LEAFREF_LEAF = "Path to the leafref leaf.";
+
+    /**
+     * Creates an instance of yang error message constants.
+     */
+    private YangErrMsgConstants() {
+    }
+}