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;
21 * The <code>default</code> implementation of Bits Type Definition interface.
23 * @see BitsTypeDefinition
25 public class BitsType implements BitsTypeDefinition {
27 private final QName name = BaseTypes.constructQName("bits");
28 private final SchemaPath path = BaseTypes.schemaPath(name);
29 private final String description = "The bits built-in type represents a bit set. " +
30 "That is, a bits value is a set of flags identified by small integer position " +
31 "numbers starting at 0. Each bit number has an assigned name.";
33 private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
35 private final List<Bit> bits;
36 private String units = "";
39 * Default constructor. <br>
40 * Instantiates Bits type as empty bits list.
44 bits = Collections.emptyList();
48 * Constructor with explicit definition of bits assigned to
52 * The bits assigned for Bits Type
54 public BitsType(final List<Bit> bits) {
56 this.bits = Collections.unmodifiableList(bits);
61 * Constructor with explicit definition of bits assigned to
64 * The default value of Bits Type is List of bits.
66 * @param bits The bits assigned for Bits Type
67 * @param units units for bits type
69 public BitsType(List<Bit> bits, String units) {
71 this.bits = Collections.unmodifiableList(bits);
78 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
81 public BitsTypeDefinition getBaseType() {
88 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
91 public String getUnits() {
98 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
101 public Object getDefaultValue() {
108 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
111 public QName getQName() {
118 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
121 public SchemaPath getPath() {
128 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
131 public String getDescription() {
138 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
141 public String getReference() {
148 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
151 public Status getStatus() {
152 return Status.CURRENT;
156 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
157 return Collections.emptyList();
161 public List<Bit> getBits() {
166 public int hashCode() {
167 final int prime = 31;
169 result = prime * result + ((bits == null) ? 0 : bits.hashCode());
170 result = prime * result
171 + ((description == null) ? 0 : description.hashCode());
172 result = prime * result + ((name == null) ? 0 : name.hashCode());
173 result = prime * result + ((path == null) ? 0 : path.hashCode());
174 result = prime * result
175 + ((reference == null) ? 0 : reference.hashCode());
176 result = prime * result + ((units == null) ? 0 : units.hashCode());
181 public boolean equals(Object obj) {
188 if (getClass() != obj.getClass()) {
191 BitsType other = (BitsType) obj;
193 if (other.bits != null) {
196 } else if (!bits.equals(other.bits)) {
199 if (description == null) {
200 if (other.description != null) {
203 } else if (!description.equals(other.description)) {
207 if (other.name != null) {
210 } else if (!name.equals(other.name)) {
214 if (other.path != null) {
217 } else if (!path.equals(other.path)) {
220 if (reference == null) {
221 if (other.reference != null) {
224 } else if (!reference.equals(other.reference)) {
228 if (other.units != null) {
231 } else if (!units.equals(other.units)) {
238 public String toString() {
239 StringBuilder builder = new StringBuilder();
240 builder.append("BitsType [name=");
241 builder.append(name);
242 builder.append(", path=");
243 builder.append(path);
244 builder.append(", description=");
245 builder.append(description);
246 builder.append(", reference=");
247 builder.append(reference);
248 builder.append(", bits=");
249 builder.append(bits);
250 builder.append(", units=");
251 builder.append(units);
253 return builder.toString();