blob: d519925110e603147ac8d9e9fd0b79d1dd3bed9e [file] [log] [blame]
Vinod Kumar S2ff139c2016-02-16 01:37:16 +05301/*
2 * Copyright 2016 Open Networking Laboratory
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
17package org.onosproject.yangutils.datamodel;
18
19import java.util.HashSet;
20import java.util.Set;
21
22import org.onosproject.yangutils.datamodel.exceptions.DataModelException;
23import org.onosproject.yangutils.parser.Parsable;
24import org.onosproject.yangutils.parser.ParsableDataType;
25
26/*
27 * Reference RFC 6020.
28 *
29 * The bits built-in type represents a bit set. That is, a bits value
30 * is a set of flags identified by small integer position numbers
31 * starting at 0. Each bit number has an assigned name.
32 */
33
34/**
35 * Maintains the bits data type information.
36 */
37public class YangBits implements Parsable {
38
39 private Set<YangBit> bitSet;
40
41 /**
42 * Create a YANG bits type object.
43 */
44 public YangBits() {
45 setBitSet(new HashSet<YangBit>());
46 }
47
48 /**
49 * Get the bit set.
50 *
51 * @return the bit set
52 */
53 public Set<YangBit> getBitSet() {
54 return bitSet;
55 }
56
57 /**
58 * set the bit set.
59 *
60 * @param bitSet the bit set
61 */
62 private void setBitSet(Set<YangBit> bitSet) {
63 this.bitSet = bitSet;
64 }
65
66 /**
67 * Add bit info.
68 *
69 * @param bitInfo the bit Info to add.
70 */
71 public void addBitInfo(YangBit bitInfo) {
72 getBitSet().add(bitInfo);
73 }
74
75 /**
76 * Returns the type of the data.
77 *
78 * @return ParsedDataType returns BITS_DATA
79 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053080 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053081 public ParsableDataType getParsableDataType() {
82 return ParsableDataType.BITS_DATA;
83 }
84
85 /**
86 * Validate the data on entering the corresponding parse tree node.
87 *
88 * @throws DataModelException a violation of data model rules.
89 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +053090 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +053091 public void validateDataOnEntry() throws DataModelException {
92 // TODO auto-generated method stub, to be implemented by parser
93 }
94
95 /**
96 * Validate the data on exiting the corresponding parse tree node.
97 *
98 * @throws DataModelException a violation of data model rules.
99 */
Vinod Kumar S0c330cd2016-02-23 22:36:57 +0530100 @Override
Vinod Kumar S2ff139c2016-02-16 01:37:16 +0530101 public void validateDataOnExit() throws DataModelException {
102 // TODO auto-generated method stub, to be implemented by parser
103 }
104}