blob: 5db6b549b0e5c88193c03324c271f14183e546af [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 saraswal96dfef02016-06-16 00:29:12 +053019import java.io.Serializable;
Bharat saraswald9822e92016-04-05 15:13:44 +053020import java.util.Objects;
21
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053022import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
Bharat saraswal96dfef02016-06-16 00:29:12 +053023import org.onosproject.yangutils.datamodel.utils.Parsable;
24import org.onosproject.yangutils.datamodel.utils.YangConstructType;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053025
26/*-
27 * The "bit" statement, which is a sub-statement to the "type" statement,
28 * MUST be present if the type is "bits". It is repeatedly used to
29 * specify each assigned named bit of a bits type. It takes as an
30 * argument a string that is the assigned name of the bit. It is
31 * followed by a block of sub-statements that holds detailed bit
32 * information.
33 * All assigned names in a bits type MUST be unique.
34 *
35 * The bit's sub-statements
36 *
37 * +--------------+---------+-------------+------------------+
38 * | substatement | section | cardinality |data model mapping|
39 * +--------------+---------+-------------+------------------+
40 * | description | 7.19.3 | 0..1 | - string |
41 * | reference | 7.19.4 | 0..1 | - string |
42 * | status | 7.19.2 | 0..1 | - YangStatus |
43 * | position | 9.7.4.2 | 0..1 | - int |
44 * +--------------+---------+-------------+------------------+
45 */
46
47/**
Bharat saraswald9822e92016-04-05 15:13:44 +053048 * Represents the bit data type information.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053049 */
Bharat saraswal96dfef02016-06-16 00:29:12 +053050public class YangBit implements YangCommonInfo, Parsable, Serializable {
51
52 private static final long serialVersionUID = 806201640L;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053053
54 /**
55 * Name of the bit.
56 */
57 private String bitName;
58
59 /**
60 * Description of the bit field.
61 */
62 private String description;
63
64 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +053065 * Reference info of the bit field.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053066 */
67 private String reference;
68
69 /**
70 * Status of the bit field.
71 */
72 private YangStatusType status;
73
74 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +053075 * Position of the bit whose name bit is described.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053076 */
77 private int position;
78
79 /**
80 * Create a YANG bit type object.
81 */
82 public YangBit() {
83
84 }
85
86 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +053087 * Returns bit name.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053088 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053089 * @return the bit name
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053090 */
91 public String getBitName() {
92 return bitName;
93 }
94
95 /**
Bharat saraswald9822e92016-04-05 15:13:44 +053096 * Sets the bit name.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053097 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +053098 * @param bitName the bit name to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053099 */
100 public void setBitName(String bitName) {
101 this.bitName = bitName;
102 }
103
104 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530105 * Returns description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530106 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530107 * @return 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 String getDescription() {
111 return description;
112 }
113
114 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530115 * Sets the description.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530116 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530117 * @param description set the description
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 void setDescription(String description) {
121 this.description = description;
122 }
123
124 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530125 * Returns textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530126 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530127 * @return the reference
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 String getReference() {
131 return reference;
132 }
133
134 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530135 * Sets the textual reference.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530136 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530137 * @param reference the reference to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530138 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530139 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530140 public void setReference(String reference) {
141 this.reference = reference;
142 }
143
144 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530145 * Returns status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530146 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530147 * @return the status
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 YangStatusType getStatus() {
151 return status;
152 }
153
154 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530155 * Sets the status.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530156 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530157 * @param status the status to set
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 setStatus(YangStatusType status) {
161 this.status = status;
162 }
163
164 /**
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530165 * Returns bit position.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530166 *
167 * @return the position
168 */
169 public int getPosition() {
170 return position;
171 }
172
173 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530174 * Sets the bit position.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530175 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530176 * @param position the position to set
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530177 */
178 public void setPosition(int position) {
179 this.position = position;
180 }
181
182 /**
183 * Returns the type of the data.
184 *
185 * @return ParsedDataType returns BIT_DATA
186 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530187 @Override
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530188 public YangConstructType getYangConstructType() {
189 return YangConstructType.BIT_DATA;
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530190 }
191
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530192 @Override
193 public boolean equals(Object obj) {
Bharat saraswald9822e92016-04-05 15:13:44 +0530194
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530195 if (this == obj) {
196 return true;
197 }
198 if (obj instanceof YangBit) {
199 final YangBit other = (YangBit) obj;
Bharat saraswal96dfef02016-06-16 00:29:12 +0530200 return Objects.equals(bitName, other.bitName);
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530201 }
202 return false;
203 }
204
205 @Override
206 public int hashCode() {
Bharat saraswal96dfef02016-06-16 00:29:12 +0530207 return Objects.hashCode(bitName);
Gaurav Agrawal0cfdeed2016-02-26 02:47:39 +0530208 }
209
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530210 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530211 * Validates the data on entering the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530212 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530213 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530214 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530215 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530216 public void validateDataOnEntry() throws DataModelException {
217 // TODO auto-generated method stub, to be implemented by parser
218 }
219
220 /**
Bharat saraswald9822e92016-04-05 15:13:44 +0530221 * Validates the data on exiting the corresponding parse tree node.
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530222 *
Gaurav Agrawal8e8770a2016-02-27 03:57:50 +0530223 * @throws DataModelException a violation of data model rules
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530224 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530225 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530226 public void validateDataOnExit() throws DataModelException {
227 // TODO auto-generated method stub, to be implemented by parser
228 }
229}