Bug 6871: [YANG 1.1] Allow "must" in "input", "output" and "notification statements"
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / ConstraintDefinition.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.model.api;
9
10 import java.util.Set;
11 import javax.annotation.Nullable;
12
13 /**
14  * Contains method which returns various data constraints for some YANG element
15  * (e.g. min or max number of elements). Not all constraints are allowed for all
16  * YANG element therefore if the constraint doesn't have sense for some element
17  * then the method returns <code>null</code> value.
18  */
19 public interface ConstraintDefinition {
20
21     /**
22      * Specifies the condition when the data node which contains
23      * <code>when</code> YANG substatement has to be present. If XPath
24      * expression is evaluated as true then the data node has to be present.
25      *
26      * @return XPath expression.
27      */
28     RevisionAwareXPath getWhenCondition();
29
30     /**
31      * Specifies the rules which the node which contains <code>must</code> YANG
32      * substatement has to match.
33      *
34      *
35      * @return set of <code>MustDefinition</code> (XPath) instances which
36      *         represents the concrete data constraints
37      */
38     Set<MustDefinition> getMustConstraints();
39
40     /**
41      * Expreses if the presence of the data element for which this constraint is
42      * specified is|isn't required.
43      *
44      * Contains the value of the <b>mandatory</b> YANG substatement.
45      *
46      * It is used with YANG statements leaf, choice, anyxml, deviate.
47      *
48      * @return boolean value:
49      *         <ul>
50      *         <li>true - if <code>mandatory</code> YANG keyword argument =
51      *         <i>true</i></li>
52      *         <li>false - if <code>mandatory</code> YANG keyword argument =
53      *         <i>false</i></li>
54      *         </ul>
55      */
56     boolean isMandatory();
57
58     /**
59      * Returns the minimum required number of data elements for node where this
60      * constraint is specified.
61      *
62      * The returning value equals to value of the argument of the
63      * <b>min-elements</b> YANG substatement.
64      *
65      * It is used with YANG statements leaf-list, list, deviate.
66      *
67      * @return integer with minimal number of elements, or null if no minimum is defined
68      */
69     @Nullable Integer getMinElements();
70
71     /**
72      * Returns the maximum admissible number of data elements for node where
73      * this constraint is specified.
74      *
75      * The returning value equals to value of the argument of the
76      * <b>max-elements</b> YANG substatement.
77      *
78      * It is used with YANG statements leaf-list, list, deviate.
79      *
80      * @return integer with maximum number of elements, or null if no maximum is defined
81      */
82     @Nullable Integer getMaxElements();
83 }