Merge "Fix for messags at the boot up time This commit proposes following two sets...
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / model / util / BitsType.java
1 /*\r
2   * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
3   *\r
4   * This program and the accompanying materials are made available under the\r
5   * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6   * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7   */\r
8 package org.opendaylight.controller.model.util;\r
9 \r
10 import java.util.Collections;\r
11 import java.util.List;\r
12 \r
13 import org.opendaylight.controller.model.api.type.BitsTypeDefinition;\r
14 import org.opendaylight.controller.yang.common.QName;\r
15 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
16 import org.opendaylight.controller.yang.model.api.Status;\r
17 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
18 \r
19 \r
20 /**\r
21  * The <code>default</code> implementation of Bits Type Definition interface.\r
22  * \r
23  * @see BitsTypeDefinition\r
24  */\r
25 public class BitsType implements BitsTypeDefinition {\r
26 \r
27     private final QName name = BaseTypes.constructQName("bits");\r
28     private final SchemaPath path = BaseTypes.schemaPath(name);\r
29     private final String description = "The bits built-in type represents a bit set.  " +\r
30                 "That is, a bits value is a set of flags identified by small integer position " +\r
31                 "numbers starting at 0.  Each bit number has an assigned name.";\r
32     \r
33     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";\r
34 \r
35     private final List<Bit> bits;\r
36     private String units = "";\r
37 \r
38     /**\r
39      * Default constructor. <br>\r
40      * Instantiates Bits type as empty bits list.\r
41      */\r
42     public BitsType() {\r
43         super();\r
44         bits = Collections.emptyList();\r
45     }\r
46 \r
47     /**\r
48      * Constructor with explicit definition of bits assigned to\r
49      * BitsType.\r
50      * \r
51      * @param bits\r
52      *            The bits assigned for Bits Type\r
53      */\r
54     public BitsType(final List<Bit> bits) {\r
55         super();\r
56         this.bits = Collections.unmodifiableList(bits);\r
57         this.units = "";\r
58     }\r
59 \r
60     /**\r
61      * Constructor with explicit definition of bits assigned to\r
62      * BitsType and Units.\r
63      * <br>\r
64      * The default value of Bits Type is List of bits.\r
65      * \r
66      * @param bits The bits assigned for Bits Type\r
67      * @param units units for bits type\r
68      */\r
69     public BitsType(List<Bit> bits, String units) {\r
70         super();\r
71         this.bits = Collections.unmodifiableList(bits);\r
72         this.units = units;\r
73     }\r
74 \r
75     /*\r
76      * (non-Javadoc)\r
77      * \r
78      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
79      */\r
80     @Override\r
81     public BitsTypeDefinition getBaseType() {\r
82         return this;\r
83     }\r
84 \r
85     /*\r
86      * (non-Javadoc)\r
87      * \r
88      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
89      */\r
90     @Override\r
91     public String getUnits() {\r
92         return units;\r
93     }\r
94 \r
95     /*\r
96      * (non-Javadoc)\r
97      * \r
98      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
99      */\r
100     @Override\r
101     public Object getDefaultValue() {\r
102         return bits;\r
103     }\r
104 \r
105     /*\r
106      * (non-Javadoc)\r
107      * \r
108      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
109      */\r
110     @Override\r
111     public QName getQName() {\r
112         return name;\r
113     }\r
114 \r
115     /*\r
116      * (non-Javadoc)\r
117      * \r
118      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
119      */\r
120     @Override\r
121     public SchemaPath getPath() {\r
122         return path;\r
123     }\r
124 \r
125     /*\r
126      * (non-Javadoc)\r
127      * \r
128      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
129      */\r
130     @Override\r
131     public String getDescription() {\r
132         return description;\r
133     }\r
134 \r
135     /*\r
136      * (non-Javadoc)\r
137      * \r
138      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
139      */\r
140     @Override\r
141     public String getReference() {\r
142         return reference;\r
143     }\r
144 \r
145     /*\r
146      * (non-Javadoc)\r
147      * \r
148      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
149      */\r
150     @Override\r
151     public Status getStatus() {\r
152         return Status.CURRENT;\r
153     }\r
154 \r
155     @Override\r
156     public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
157         return Collections.emptyList();\r
158     }\r
159 \r
160     @Override\r
161     public List<Bit> getBits() {\r
162         return bits;\r
163     }\r
164 \r
165     @Override\r
166     public int hashCode() {\r
167         final int prime = 31;\r
168         int result = 1;\r
169         result = prime * result + ((bits == null) ? 0 : bits.hashCode());\r
170         result = prime * result\r
171                 + ((description == null) ? 0 : description.hashCode());\r
172         result = prime * result + ((name == null) ? 0 : name.hashCode());\r
173         result = prime * result + ((path == null) ? 0 : path.hashCode());\r
174         result = prime * result\r
175                 + ((reference == null) ? 0 : reference.hashCode());\r
176         result = prime * result + ((units == null) ? 0 : units.hashCode());\r
177         return result;\r
178     }\r
179 \r
180     @Override\r
181     public boolean equals(Object obj) {\r
182         if (this == obj) {\r
183             return true;\r
184         }\r
185         if (obj == null) {\r
186             return false;\r
187         }\r
188         if (getClass() != obj.getClass()) {\r
189             return false;\r
190         }\r
191         BitsType other = (BitsType) obj;\r
192         if (bits == null) {\r
193             if (other.bits != null) {\r
194                 return false;\r
195             }\r
196         } else if (!bits.equals(other.bits)) {\r
197             return false;\r
198         }\r
199         if (description == null) {\r
200             if (other.description != null) {\r
201                 return false;\r
202             }\r
203         } else if (!description.equals(other.description)) {\r
204             return false;\r
205         }\r
206         if (name == null) {\r
207             if (other.name != null) {\r
208                 return false;\r
209             }\r
210         } else if (!name.equals(other.name)) {\r
211             return false;\r
212         }\r
213         if (path == null) {\r
214             if (other.path != null) {\r
215                 return false;\r
216             }\r
217         } else if (!path.equals(other.path)) {\r
218             return false;\r
219         }\r
220         if (reference == null) {\r
221             if (other.reference != null) {\r
222                 return false;\r
223             }\r
224         } else if (!reference.equals(other.reference)) {\r
225             return false;\r
226         }\r
227         if (units == null) {\r
228             if (other.units != null) {\r
229                 return false;\r
230             }\r
231         } else if (!units.equals(other.units)) {\r
232             return false;\r
233         }\r
234         return true;\r
235     }\r
236 \r
237     @Override\r
238     public String toString() {\r
239         StringBuilder builder = new StringBuilder();\r
240         builder.append("BitsType [name=");\r
241         builder.append(name);\r
242         builder.append(", path=");\r
243         builder.append(path);\r
244         builder.append(", description=");\r
245         builder.append(description);\r
246         builder.append(", reference=");\r
247         builder.append(reference);\r
248         builder.append(", bits=");\r
249         builder.append(bits);\r
250         builder.append(", units=");\r
251         builder.append(units);\r
252         builder.append("]");\r
253         return builder.toString();\r
254     }\r
255 }\r