Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 0f7908b | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2016-present Open Networking Laboratory |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package org.onosproject.yangutils.datamodel; |
| 17 | |
| 18 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 19 | import org.onosproject.yangutils.parser.Parsable; |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 20 | import org.onosproject.yangutils.utils.YangConstructType; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 21 | |
| 22 | /*- |
| 23 | * The "must" statement, which is optional, takes as an argument a string that |
| 24 | * contains an XPath expression. It is used to formally declare a constraint |
| 25 | * on valid data. |
| 26 | * |
| 27 | * When a datastore is validated, all "must" constraints are conceptually |
| 28 | * evaluated once for each data node in the data tree, and for all leafs with |
| 29 | * default values in use. If a data node does not exist in the data tree, and |
| 30 | * it does not have a default value, its "must" statements are not evaluated. |
| 31 | * |
| 32 | * All such constraints MUST evaluate to true for the data to be valid. |
| 33 | * |
| 34 | * The must's sub-statements |
| 35 | * |
| 36 | * +---------------+---------+-------------+------------------+ |
| 37 | * | substatement | section | cardinality |data model mapping| |
| 38 | * +---------------+---------+-------------+------------------+ |
| 39 | * | description | 7.19.3 | 0..1 | -string | |
| 40 | * | error-app-tag | 7.5.4.2 | 0..1 | -not supported | |
| 41 | * | error-message | 7.5.4.1 | 0..1 | -not supported | |
| 42 | * | reference | 7.19.4 | 0..1 | -string | |
| 43 | * +---------------+---------+-------------+------------------+ |
| 44 | */ |
| 45 | |
| 46 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 47 | * Represents information defined in YANG must. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 48 | */ |
| 49 | public class YangMust implements YangDesc, YangReference, Parsable { |
| 50 | |
| 51 | /** |
| 52 | * Constraint info. |
| 53 | */ |
| 54 | private String constratint; |
| 55 | |
| 56 | /** |
| 57 | * Description string. |
| 58 | */ |
| 59 | private String description; |
| 60 | |
| 61 | /** |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 62 | * Reference string. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 63 | */ |
| 64 | private String reference; |
| 65 | |
| 66 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 67 | * Creates a YANG must restriction. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 68 | */ |
| 69 | public YangMust() { |
| 70 | } |
| 71 | |
| 72 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 73 | * Returns the constraint. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 74 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 75 | * @return the constraint |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 76 | */ |
| 77 | public String getConstratint() { |
| 78 | return constratint; |
| 79 | } |
| 80 | |
| 81 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 82 | * Sets the constraint. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 83 | * |
| 84 | * @param constratint the constraint to set |
| 85 | */ |
| 86 | public void setConstratint(String constratint) { |
| 87 | this.constratint = constratint; |
| 88 | } |
| 89 | |
| 90 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 91 | * Returns the description. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 92 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 93 | * @return the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 94 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 95 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 96 | public String getDescription() { |
| 97 | return description; |
| 98 | } |
| 99 | |
| 100 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 101 | * Sets the description. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 102 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 103 | * @param description set the description |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 104 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 105 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 106 | public void setDescription(String description) { |
| 107 | this.description = description; |
| 108 | } |
| 109 | |
| 110 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 111 | * Returns the textual reference. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 112 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 113 | * @return the reference |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 114 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 115 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 116 | public String getReference() { |
| 117 | return reference; |
| 118 | } |
| 119 | |
| 120 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 121 | * Sets the textual reference. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 122 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 123 | * @param reference the reference to set |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 124 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 125 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 126 | public void setReference(String reference) { |
| 127 | this.reference = reference; |
| 128 | } |
| 129 | |
| 130 | /** |
| 131 | * Returns the type of the parsed data. |
| 132 | * |
| 133 | * @return returns MUST_DATA |
| 134 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 135 | @Override |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 136 | public YangConstructType getYangConstructType() { |
| 137 | return YangConstructType.MUST_DATA; |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 141 | * Validates the data on entering the corresponding parse tree node. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 142 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 143 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 144 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 145 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 146 | public void validateDataOnEntry() throws DataModelException { |
| 147 | // TODO auto-generated method stub, to be implemented by parser |
| 148 | } |
| 149 | |
| 150 | /** |
Bharat saraswal | 63f26fb | 2016-04-05 15:13:44 +0530 | [diff] [blame^] | 151 | * Validates the data on exiting the corresponding parse tree node. |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 152 | * |
Gaurav Agrawal | db828bd | 2016-02-27 03:57:50 +0530 | [diff] [blame] | 153 | * @throws DataModelException a violation of data model rules |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 154 | */ |
Vinod Kumar S | c26bf19 | 2016-02-23 22:36:57 +0530 | [diff] [blame] | 155 | @Override |
Vinod Kumar S | 5a39e01 | 2016-02-16 01:37:16 +0530 | [diff] [blame] | 156 | public void validateDataOnExit() throws DataModelException { |
| 157 | // TODO auto-generated method stub, to be implemented by parser |
| 158 | } |
| 159 | } |