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 {
25 private final QName name = BaseTypes.constructQName("bits");
26 private final SchemaPath path;
27 private final String description = "The bits built-in type represents a bit set. "
28 + "That is, a bits value is a set of flags identified by small integer position "
29 + "numbers starting at 0. Each bit number has an assigned name.";
31 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
32 private final BitsTypeDefinition baseType;
33 private final List<Bit> bits;
34 private final String units = "";
37 * Default constructor. <br>
38 * Instantiates Bits type as empty bits list.
40 public BitsType(final SchemaPath path) {
42 this.bits = Collections.emptyList();
48 * Constructor with explicit definition of bits assigned to BitsType.
54 * The bits assigned for Bits Type
56 public BitsType(final SchemaPath path, final List<Bit> bits) {
58 this.bits = Collections.unmodifiableList(bits);
67 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
70 public BitsTypeDefinition getBaseType() {
77 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
80 public String getUnits() {
88 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
92 public Object getDefaultValue() {
99 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
102 public QName getQName() {
109 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
112 public SchemaPath getPath() {
120 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
123 public String getDescription() {
130 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
133 public String getReference() {
140 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
143 public Status getStatus() {
144 return Status.CURRENT;
148 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
149 return Collections.emptyList();
153 public List<Bit> getBits() {
158 public int hashCode() {
159 final int prime = 31;
161 result = prime * result + ((bits == null) ? 0 : bits.hashCode());
162 result = prime * result
163 + ((description == null) ? 0 : description.hashCode());
164 result = prime * result + ((name == null) ? 0 : name.hashCode());
165 result = prime * result + ((path == null) ? 0 : path.hashCode());
166 result = prime * result
167 + ((reference == null) ? 0 : reference.hashCode());
168 result = prime * result + ((units == null) ? 0 : units.hashCode());
173 public boolean equals(Object obj) {
180 if (getClass() != obj.getClass()) {
183 BitsType other = (BitsType) obj;
185 if (other.bits != null) {
188 } else if (!bits.equals(other.bits)) {
191 if (description == null) {
192 if (other.description != null) {
195 } else if (!description.equals(other.description)) {
199 if (other.name != null) {
202 } else if (!name.equals(other.name)) {
206 if (other.path != null) {
209 } else if (!path.equals(other.path)) {
212 if (reference == null) {
213 if (other.reference != null) {
216 } else if (!reference.equals(other.reference)) {
220 if (other.units != null) {
223 } else if (!units.equals(other.units)) {
230 public String toString() {
231 StringBuilder builder = new StringBuilder();
232 builder.append("BitsType [name=");
233 builder.append(name);
234 builder.append(", path=");
235 builder.append(path);
236 builder.append(", description=");
237 builder.append(description);
238 builder.append(", reference=");
239 builder.append(reference);
240 builder.append(", bits=");
241 builder.append(bits);
242 builder.append(", units=");
243 builder.append(units);
245 return builder.toString();