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.
42 public BitsType(final SchemaPath path) {
44 this.bits = Collections.emptyList();
50 * Constructor with explicit definition of bits assigned to BitsType.
55 public BitsType(final SchemaPath path, final List<Bit> bits) {
57 this.bits = Collections.unmodifiableList(bits);
66 * org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
69 public BitsTypeDefinition getBaseType() {
76 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
79 public String getUnits() {
87 * org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue
91 public Object getDefaultValue() {
98 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
101 public QName getQName() {
108 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
111 public SchemaPath getPath() {
119 * org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
122 public String getDescription() {
129 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
132 public String getReference() {
139 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
142 public Status getStatus() {
143 return Status.CURRENT;
147 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
148 return Collections.emptyList();
152 public List<Bit> getBits() {
157 public int hashCode() {
158 final int prime = 31;
160 result = prime * result + ((bits == null) ? 0 : bits.hashCode());
161 result = prime * result + ((description == null) ? 0 : description.hashCode());
162 result = prime * result + ((name == null) ? 0 : name.hashCode());
163 result = prime * result + ((path == null) ? 0 : path.hashCode());
164 result = prime * result + ((reference == null) ? 0 : reference.hashCode());
165 result = prime * result + ((units == null) ? 0 : units.hashCode());
170 public boolean equals(Object obj) {
177 if (getClass() != obj.getClass()) {
180 BitsType other = (BitsType) obj;
182 if (other.bits != null) {
185 } else if (!bits.equals(other.bits)) {
188 if (description == null) {
189 if (other.description != null) {
192 } else if (!description.equals(other.description)) {
196 if (other.name != null) {
199 } else if (!name.equals(other.name)) {
203 if (other.path != null) {
206 } else if (!path.equals(other.path)) {
209 if (reference == null) {
210 if (other.reference != null) {
213 } else if (!reference.equals(other.reference)) {
217 if (other.units != null) {
220 } else if (!units.equals(other.units)) {
227 public String toString() {
228 StringBuilder builder = new StringBuilder();
229 builder.append("BitsType [name=");
230 builder.append(name);
231 builder.append(", path=");
232 builder.append(path);
233 builder.append(", description=");
234 builder.append(description);
235 builder.append(", reference=");
236 builder.append(reference);
237 builder.append(", bits=");
238 builder.append(bits);
239 builder.append(", units=");
240 builder.append(units);
242 return builder.toString();