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.yangtools.yang.model.util;
10 import java.util.Collections;
11 import java.util.List;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
15 import org.opendaylight.yangtools.yang.model.api.Status;
16 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
17 import org.opendaylight.yangtools.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 static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.7";
32 private final List<Bit> bits;
33 private static final String UNITS = "";
36 * Default constructor. <br>
37 * Instantiates Bits type as empty bits list.
41 public BitsType(final SchemaPath path) {
43 this.bits = Collections.emptyList();
48 * Constructor with explicit definition of bits assigned to BitsType.
53 public BitsType(final SchemaPath path, final List<Bit> bits) {
55 this.bits = Collections.unmodifiableList(bits);
63 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
66 public BitsTypeDefinition getBaseType() {
73 * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
76 public String getUnits() {
84 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
88 public Object getDefaultValue() {
95 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
98 public QName getQName() {
105 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
108 public SchemaPath getPath() {
116 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
119 public String getDescription() {
126 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
129 public String getReference() {
136 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
139 public Status getStatus() {
140 return Status.CURRENT;
144 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
145 return Collections.emptyList();
149 public List<Bit> getBits() {
154 public int hashCode() {
155 final int prime = 31;
157 result = prime * result + ((bits == null) ? 0 : bits.hashCode());
158 result = prime * result + ((description == null) ? 0 : description.hashCode());
159 result = prime * result + ((name == null) ? 0 : name.hashCode());
160 result = prime * result + ((path == null) ? 0 : path.hashCode());
165 public boolean equals(Object obj) {
172 if (getClass() != obj.getClass()) {
175 BitsType other = (BitsType) obj;
177 if (other.bits != null) {
180 } else if (!bits.equals(other.bits)) {
183 if (description == null) {
184 if (other.description != null) {
187 } else if (!description.equals(other.description)) {
191 if (other.name != null) {
194 } else if (!name.equals(other.name)) {
198 if (other.path != null) {
201 } else if (!path.equals(other.path)) {
208 public String toString() {
209 StringBuilder builder = new StringBuilder();
210 builder.append("BitsType [name=");
211 builder.append(name);
212 builder.append(", path=");
213 builder.append(path);
214 builder.append(", description=");
215 builder.append(description);
216 builder.append(", reference=");
217 builder.append(REFERENCE);
218 builder.append(", bits=");
219 builder.append(bits);
220 builder.append(", units=");
221 builder.append(UNITS);
223 return builder.toString();