blob: 4449b6a1a76c58eb994aa911e7d280c4abc0c35d [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 */
16
17package org.onosproject.yangutils.datamodel;
18
Bharat saraswald9822e92016-04-05 15:13:44 +053019import java.util.Objects;
20
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053021import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
22import org.onosproject.yangutils.parser.Parsable;
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053023import org.onosproject.yangutils.utils.YangConstructType;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053024
25/*-
26 * The "bit" statement, which is a sub-statement to the "type" statement,
27 * MUST be present if the type is "bits". It is repeatedly used to
28 * specify each assigned named bit of a bits type. It takes as an
29 * argument a string that is the assigned name of the bit. It is
30 * followed by a block of sub-statements that holds detailed bit
31 * information.
32 * All assigned names in a bits type MUST be unique.
33 *
34 * The bit's sub-statements
35 *
36 * +--------------+---------+-------------+------------------+
37 * | substatement | section | cardinality |data model mapping|
38 * +--------------+---------+-------------+------------------+
39 * | description | 7.19.3 | 0..1 | - string |
40 * | reference | 7.19.4 | 0..1 | - string |
41 * | status | 7.19.2 | 0..1 | - YangStatus |
42 * | position | 9.7.4.2 | 0..1 | - int |
43 * +--------------+---------+-------------+------------------+
44 */
45
46/**
Bharat saraswald9822e92016-04-05 15:13:44 +053047 * Represents the bit data type information.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053048 */
49public class YangBit implements YangCommonInfo, Parsable {
50
51 /**
52 * Name of the bit.
53 */
54 private String bitName;
55
56 /**
57 * Description of the bit field.
58 */
59 private String description;
60
61 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +053062 * Reference info of the bit field.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053063 */
64 private String reference;
65
66 /**
67 * Status of the bit field.
68 */
69 private YangStatusType status;
70
71 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +053072 * Position of the bit whose name bit is described.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053073 */
74 private int position;
75
76 /**
77 * Create a YANG bit type object.
78 */
79 public YangBit() {
80
81 }
82
83 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +053084 * Returns bit name.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053085 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053086 * @return the bit name
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053087 */
88 public String getBitName() {
89 return bitName;
90 }
91
92 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053093 * Sets the bit name.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053094 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053095 * @param bitName the bit name to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053096 */
97 public void setBitName(String bitName) {
98 this.bitName = bitName;
99 }
100
101 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530102 * Returns description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530103 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530104 * @return the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530105 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530106 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530107 public String getDescription() {
108 return description;
109 }
110
111 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530112 * Sets the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530113 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530114 * @param description set the description
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530115 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530116 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530117 public void setDescription(String description) {
118 this.description = description;
119 }
120
121 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530122 * Returns textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530123 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530124 * @return the reference
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530125 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530126 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530127 public String getReference() {
128 return reference;
129 }
130
131 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530132 * Sets the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530133 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530134 * @param reference the reference to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530135 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530136 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530137 public void setReference(String reference) {
138 this.reference = reference;
139 }
140
141 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530142 * Returns status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530143 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530144 * @return the status
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530145 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530146 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530147 public YangStatusType getStatus() {
148 return status;
149 }
150
151 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530152 * Sets the status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530153 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530154 * @param status the status to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530155 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530156 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530157 public void setStatus(YangStatusType status) {
158 this.status = status;
159 }
160
161 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530162 * Returns bit position.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530163 *
164 * @return the position
165 */
166 public int getPosition() {
167 return position;
168 }
169
170 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530171 * Sets the bit position.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530172 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530173 * @param position the position to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530174 */
175 public void setPosition(int position) {
176 this.position = position;
177 }
178
179 /**
180 * Returns the type of the data.
181 *
182 * @return ParsedDataType returns BIT_DATA
183 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530184 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530185 public YangConstructType getYangConstructType() {
186 return YangConstructType.BIT_DATA;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530187 }
188
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530189 @Override
190 public boolean equals(Object obj) {
Bharat saraswald9822e92016-04-05 15:13:44 +0530191
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530192 if (this == obj) {
193 return true;
194 }
195 if (obj instanceof YangBit) {
196 final YangBit other = (YangBit) obj;
197 return Objects.equals(this.bitName, other.bitName);
198 }
199 return false;
200 }
201
202 @Override
203 public int hashCode() {
204 return Objects.hashCode(this.bitName);
205 }
206
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530207 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530208 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530209 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530210 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530211 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530212 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530213 public void validateDataOnEntry() throws DataModelException {
214 // TODO auto-generated method stub, to be implemented by parser
215 }
216
217 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530218 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530219 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530220 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530221 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530222 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530223 public void validateDataOnExit() throws DataModelException {
224 // TODO auto-generated method stub, to be implemented by parser
225 }
226}