Bug 4662: Introduce a SemanticVersion concept - import processing
[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
12 /**
13  * Contains method which returns various data constraints for some YANG element
14  * (e.g. min or max number of elements). Not all constraints are allowed for all
15  * YANG element therefore if the constraint doesn't have sense for some element
16  * then the method returns <code>null</code> value.
17  */
18 public interface ConstraintDefinition {
19
20     /**
21      * Specifies the condition when the data node which contains
22      * <code>when</code> YANG substatement has to be present. If XPath
23      * expression is evaluated as true then the data node has to be present.
24      * 
25      * @return XPath expression.
26      */
27     RevisionAwareXPath getWhenCondition();
28
29     /**
30      * Specifies the rules which the node which contains <code>must</code> YANG
31      * substatement has to match.
32      * 
33      * 
34      * @return set of <code>MustDefinition</code> (XPath) instances which
35      *         represents the concrete data constraints
36      */
37     Set<MustDefinition> getMustConstraints();
38
39     /**
40      * Expreses if the presence of the data element for which this constraint is
41      * specified is|isn't required.
42      * 
43      * Contains the value of the <b>mandatory</b> YANG substatement.
44      * 
45      * It is used with YANG statements leaf, choice, anyxml, deviate.
46      * 
47      * @return boolean value:
48      *         <ul>
49      *         <li>true - if <code>mandatory</code> YANG keyword argument =
50      *         <i>true</i></li>
51      *         <li>false - if <code>mandatory</code> YANG keyword argument =
52      *         <i>false</i></li>
53      *         </ul>
54      */
55     boolean isMandatory();
56
57     /**
58      * Returns the minimum required number of data elements for node where this
59      * constraint is specified.
60      * 
61      * The returning value equals to value of the argument of the
62      * <b>min-elements</b> YANG substatement.
63      * 
64      * It is used with YANG statements leaf-list, list, deviate.
65      * 
66      * @return integer with minimal number of elements
67      */
68     Integer getMinElements();
69
70     /**
71      * Returns the maximum admissible number of data elements for node where
72      * this constraint is specified.
73      * 
74      * The returning value equals to value of the argument of the
75      * <b>max-elements</b> YANG substatement.
76      * 
77      * It is used with YANG statements leaf-list, list, deviate.
78      * 
79      * @return integer with maximum number of elements
80      */
81     Integer getMaxElements();
82 }