Merge "Added initial draft of Normalized Yang Data Tree model."
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / ConstraintDefinition.java
index 349a2ba1e6b8f096b14c27806ae3ab66bc89eaba..c201545d8ca98849f3aa3cd6f51a350626a768c3 100644 (file)
@@ -1,23 +1,82 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.model.api;\r
-\r
-import java.util.Set;\r
-\r
-public interface ConstraintDefinition {\r
-\r
-    RevisionAwareXPath getWhenCondition();\r
-\r
-    Set<MustDefinition> getMustConstraints();\r
-\r
-    boolean isMandatory();\r
-\r
-    Integer getMinElements();\r
-\r
-    Integer getMaxElements();\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.api;
+
+import java.util.Set;
+
+/**
+ * Contains method which returns various data constraints for some YANG element
+ * (e.g. min or max number of elements). Not all constraints are allowed for all
+ * YANG element therefore if the constraint doesn't have sense for some element
+ * then the method returns <code>null</code> value.
+ */
+public interface ConstraintDefinition {
+
+    /**
+     * Specifies the condition when the data node which contains
+     * <code>when</code> YANG substatement has to be present. If XPath
+     * expression is evaluated as true then the data node has to be present.
+     * 
+     * @return XPath expression.
+     */
+    RevisionAwareXPath getWhenCondition();
+
+    /**
+     * Specifies the rules which the node which contains <code>must</code> YANG
+     * substatement has to match.
+     * 
+     * 
+     * @return set of <code>MustDefinition</code> (XPath) instances which
+     *         represents the concrete data constraints
+     */
+    Set<MustDefinition> getMustConstraints();
+
+    /**
+     * Expreses if the presence of the data element for which this constraint is
+     * specified is|isn't required.
+     * 
+     * Contains the value of the <b>mandatory</b> YANG substatement.
+     * 
+     * It is used with YANG statements leaf, choice, anyxml, deviate.
+     * 
+     * @return boolean value:
+     *         <ul>
+     *         <li>true - if <code>mandatory</code> YANG keyword argument =
+     *         <i>true</i></li>
+     *         <li>false - if <code>mandatory</code> YANG keyword argument =
+     *         <i>false</i></li>
+     *         </ul>
+     */
+    boolean isMandatory();
+
+    /**
+     * Returns the minimum required number of data elements for node where this
+     * constraint is specified.
+     * 
+     * The returning value equals to value of the argument of the
+     * <b>min-elements</b> YANG substatement.
+     * 
+     * It is used with YANG statements leaf-list, list, deviate.
+     * 
+     * @return integer with minimal number of elements
+     */
+    Integer getMinElements();
+
+    /**
+     * Returns the maximum admissible number of data elements for node where
+     * this constraint is specified.
+     * 
+     * The returning value equals to value of the argument of the
+     * <b>max-elements</b> YANG substatement.
+     * 
+     * It is used with YANG statements leaf-list, list, deviate.
+     * 
+     * @return integer with maximum number of elements
+     */
+    Integer getMaxElements();
+}