2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\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
8 package org.opendaylight.controller.model.util;
\r
10 import java.util.Collections;
\r
11 import java.util.List;
\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
21 * The <code>default</code> implementation of Bits Type Definition interface.
\r
23 * @see BitsTypeDefinition
\r
25 public class BitsType implements BitsTypeDefinition {
\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
33 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
\r
35 private final List<Bit> bits;
\r
36 private String units = "";
\r
39 * Default constructor. <br>
\r
40 * Instantiates Bits type as empty bits list.
\r
44 bits = Collections.emptyList();
\r
48 * Constructor with explicit definition of bits assigned to
\r
52 * The bits assigned for Bits Type
\r
54 public BitsType(final List<Bit> bits) {
\r
56 this.bits = Collections.unmodifiableList(bits);
\r
61 * Constructor with explicit definition of bits assigned to
\r
62 * BitsType and Units.
\r
64 * The default value of Bits Type is List of bits.
\r
66 * @param bits The bits assigned for Bits Type
\r
67 * @param units units for bits type
\r
69 public BitsType(List<Bit> bits, String units) {
\r
71 this.bits = Collections.unmodifiableList(bits);
\r
78 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
81 public BitsTypeDefinition getBaseType() {
\r
88 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
91 public String getUnits() {
\r
98 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
101 public Object getDefaultValue() {
\r
108 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
111 public QName getQName() {
\r
118 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
121 public SchemaPath getPath() {
\r
128 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
131 public String getDescription() {
\r
132 return description;
\r
138 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
141 public String getReference() {
\r
148 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
151 public Status getStatus() {
\r
152 return Status.CURRENT;
\r
156 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
\r
157 return Collections.emptyList();
\r
161 public List<Bit> getBits() {
\r
166 public int hashCode() {
\r
167 final int prime = 31;
\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
181 public boolean equals(Object obj) {
\r
188 if (getClass() != obj.getClass()) {
\r
191 BitsType other = (BitsType) obj;
\r
192 if (bits == null) {
\r
193 if (other.bits != null) {
\r
196 } else if (!bits.equals(other.bits)) {
\r
199 if (description == null) {
\r
200 if (other.description != null) {
\r
203 } else if (!description.equals(other.description)) {
\r
206 if (name == null) {
\r
207 if (other.name != null) {
\r
210 } else if (!name.equals(other.name)) {
\r
213 if (path == null) {
\r
214 if (other.path != null) {
\r
217 } else if (!path.equals(other.path)) {
\r
220 if (reference == null) {
\r
221 if (other.reference != null) {
\r
224 } else if (!reference.equals(other.reference)) {
\r
227 if (units == null) {
\r
228 if (other.units != null) {
\r
231 } else if (!units.equals(other.units)) {
\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