blob: c5790035940f3ab1122167fd6d7343fd9d896a3b [file] [log] [blame]
Vinod Kumar S2ff139c2016-02-16 01:37:16 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Vinod Kumar S2ff139c2016-02-16 01:37:16 +05303 *
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 */
16package org.onosproject.yangutils.datamodel;
17
Bharat saraswal96dfef02016-06-16 00:29:12 +053018import java.io.Serializable;
19
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053020import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053021import org.onosproject.yangutils.datamodel.utils.Parsable;
22import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053023
24/*-
25 * The "must" statement, which is optional, takes as an argument a string that
26 * contains an XPath expression. It is used to formally declare a constraint
27 * on valid data.
28 *
29 * When a datastore is validated, all "must" constraints are conceptually
30 * evaluated once for each data node in the data tree, and for all leafs with
31 * default values in use. If a data node does not exist in the data tree, and
32 * it does not have a default value, its "must" statements are not evaluated.
33 *
34 * All such constraints MUST evaluate to true for the data to be valid.
35 *
36 * The must's sub-statements
37 *
38 * +---------------+---------+-------------+------------------+
39 * | substatement | section | cardinality |data model mapping|
40 * +---------------+---------+-------------+------------------+
41 * | description | 7.19.3 | 0..1 | -string |
42 * | error-app-tag | 7.5.4.2 | 0..1 | -not supported |
43 * | error-message | 7.5.4.1 | 0..1 | -not supported |
44 * | reference | 7.19.4 | 0..1 | -string |
45 * +---------------+---------+-------------+------------------+
46 */
47
48/**
Bharat saraswald9822e92016-04-05 15:13:44 +053049 * Represents information defined in YANG must.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053050 */
Bharat saraswal96dfef02016-06-16 00:29:12 +053051public class YangMust implements YangDesc, YangReference, Parsable, Serializable {
52
53 private static final long serialVersionUID = 806201646L;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053054
55 /**
56 * Constraint info.
57 */
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053058 private String constraint;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053059
60 /**
61 * Description string.
62 */
63 private String description;
64
65 /**
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053066 * Reference string.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053067 */
68 private String reference;
69
70 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053071 * Creates a YANG must restriction.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053072 */
73 public YangMust() {
74 }
75
76 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053077 * Returns the constraint.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053078 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053079 * @return the constraint
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053080 */
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053081 public String getConstraint() {
82 return constraint;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053083 }
84
85 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053086 * Sets the constraint.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053087 *
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053088 * @param constraint the constraint to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053089 */
Vidyashree Ramadeac28b2016-06-20 15:12:43 +053090 public void setConstraint(String constraint) {
91 this.constraint = constraint;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053092 }
93
94 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053095 * Returns the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053096 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053097 * @return the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053098 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053099 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530100 public String getDescription() {
101 return description;
102 }
103
104 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530105 * Sets the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530106 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530107 * @param description set the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530108 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530109 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530110 public void setDescription(String description) {
111 this.description = description;
112 }
113
114 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530115 * Returns the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530116 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530117 * @return the reference
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530118 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530119 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530120 public String getReference() {
121 return reference;
122 }
123
124 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530125 * Sets the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530126 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530127 * @param reference the reference to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530128 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530129 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530130 public void setReference(String reference) {
131 this.reference = reference;
132 }
133
134 /**
135 * Returns the type of the parsed data.
136 *
137 * @return returns MUST_DATA
138 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530139 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530140 public YangConstructType getYangConstructType() {
141 return YangConstructType.MUST_DATA;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530142 }
143
144 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530145 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530146 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530147 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530148 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530149 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530150 public void validateDataOnEntry() throws DataModelException {
151 // TODO auto-generated method stub, to be implemented by parser
152 }
153
154 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530155 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530156 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530157 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530158 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530159 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530160 public void validateDataOnExit() throws DataModelException {
161 // TODO auto-generated method stub, to be implemented by parser
162 }
163}