2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.yang.model.util;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.controller.yang.common.QName;
14 import org.opendaylight.controller.yang.model.api.SchemaPath;
15 import org.opendaylight.controller.yang.model.api.Status;
16 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
20 * The <code>default</code> implementation of Bits Type Definition interface.
22 * @see BitsTypeDefinition
24 public final class BitsType implements BitsTypeDefinition {
26 private final QName name = BaseTypes.constructQName("bits");
27 private final SchemaPath path;
28 private final String description = "The bits built-in type represents a bit set. "
29 + "That is, a bits value is a set of flags identified by small integer position "
30 + "numbers starting at 0. Each bit number has an assigned name.";
32 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
33 private final BitsTypeDefinition baseType;
34 private final List<Bit> bits;
35 private String units = "";
38 * Default constructor. <br>
39 * Instantiates Bits type as empty bits list.
43 this.bits = Collections.emptyList();
44 this.path = BaseTypes.schemaPath(name);
48 public BitsType(final SchemaPath path) {
50 this.bits = Collections.emptyList();
52 this.baseType = new BitsType();
56 * Constructor with explicit definition of bits assigned to BitsType.
62 * The bits assigned for Bits Type
64 public BitsType(final SchemaPath path, final List<Bit> bits) {
66 this.bits = Collections.unmodifiableList(bits);
69 this.baseType = new BitsType();
73 * Constructor with explicit definition of bits assigned to BitsType and
75 * The default value of Bits Type is List of bits.
78 * The bits assigned for Bits Type
82 public BitsType(final SchemaPath path, List<Bit> bits, String units) {
84 this.bits = Collections.unmodifiableList(bits);
87 this.baseType = new BitsType();
94 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
97 public BitsTypeDefinition getBaseType() {
104 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
107 public String getUnits() {
115 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
119 public Object getDefaultValue() {
126 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
129 public QName getQName() {
136 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
139 public SchemaPath getPath() {
147 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
150 public String getDescription() {
157 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
160 public String getReference() {
167 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
170 public Status getStatus() {
171 return Status.CURRENT;
175 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
176 return Collections.emptyList();
180 public List<Bit> getBits() {
185 public int hashCode() {
186 final int prime = 31;
188 result = prime * result + ((bits == null) ? 0 : bits.hashCode());
189 result = prime * result
190 + ((description == null) ? 0 : description.hashCode());
191 result = prime * result + ((name == null) ? 0 : name.hashCode());
192 result = prime * result + ((path == null) ? 0 : path.hashCode());
193 result = prime * result
194 + ((reference == null) ? 0 : reference.hashCode());
195 result = prime * result + ((units == null) ? 0 : units.hashCode());
200 public boolean equals(Object obj) {
207 if (getClass() != obj.getClass()) {
210 BitsType other = (BitsType) obj;
212 if (other.bits != null) {
215 } else if (!bits.equals(other.bits)) {
218 if (description == null) {
219 if (other.description != null) {
222 } else if (!description.equals(other.description)) {
226 if (other.name != null) {
229 } else if (!name.equals(other.name)) {
233 if (other.path != null) {
236 } else if (!path.equals(other.path)) {
239 if (reference == null) {
240 if (other.reference != null) {
243 } else if (!reference.equals(other.reference)) {
247 if (other.units != null) {
250 } else if (!units.equals(other.units)) {
257 public String toString() {
258 StringBuilder builder = new StringBuilder();
259 builder.append("BitsType [name=");
260 builder.append(name);
261 builder.append(", path=");
262 builder.append(path);
263 builder.append(", description=");
264 builder.append(description);
265 builder.append(", reference=");
266 builder.append(reference);
267 builder.append(", bits=");
268 builder.append(bits);
269 builder.append(", units=");
270 builder.append(units);
272 return builder.toString();