2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.controller.model.util;
\r
10 import java.util.Collections;
\r
11 import java.util.List;
\r
13 import org.opendaylight.controller.model.api.type.BitsTypeDefinition;
\r
14 import org.opendaylight.controller.yang.common.QName;
\r
15 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
16 import org.opendaylight.controller.yang.model.api.Status;
\r
17 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
\r
19 public class BitsType implements BitsTypeDefinition {
\r
21 private final QName name = BaseTypes.constructQName("bits");
\r
22 private final SchemaPath path = BaseTypes.schemaPath(name);
\r
23 private final String description = "";
\r
24 private final String reference = "";
\r
26 private final List<Bit> bits;
\r
27 private String units = "";
\r
30 * Default constructor. <br>
\r
31 * Instantiates Bits type as empty bits list.
\r
36 bits = Collections.emptyList();
\r
40 * Overloaded constructor with explicit definition of bits assigned to
\r
44 * The bits assigned for Bits Type
\r
46 public BitsType(final List<Bit> bits) {
\r
48 this.bits = Collections.unmodifiableList(bits);
\r
52 public BitsType(List<Bit> bits, String units) {
\r
54 this.bits = Collections.unmodifiableList(bits);
\r
62 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
65 public BitsTypeDefinition getBaseType() {
\r
72 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
75 public String getUnits() {
\r
82 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
85 public Object getDefaultValue() {
\r
92 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
95 public QName getQName() {
\r
102 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
105 public SchemaPath getPath() {
\r
112 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
115 public String getDescription() {
\r
116 return description;
\r
122 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
125 public String getReference() {
\r
132 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
135 public Status getStatus() {
\r
136 return Status.CURRENT;
\r
140 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
\r
141 return Collections.emptyList();
\r
145 public List<Bit> getBits() {
\r
150 public int hashCode() {
\r
151 final int prime = 31;
\r
153 result = prime * result + ((bits == null) ? 0 : bits.hashCode());
\r
154 result = prime * result
\r
155 + ((description == null) ? 0 : description.hashCode());
\r
156 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
157 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
158 result = prime * result
\r
159 + ((reference == null) ? 0 : reference.hashCode());
\r
160 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
165 public boolean equals(Object obj) {
\r
172 if (getClass() != obj.getClass()) {
\r
175 BitsType other = (BitsType) obj;
\r
176 if (bits == null) {
\r
177 if (other.bits != null) {
\r
180 } else if (!bits.equals(other.bits)) {
\r
183 if (description == null) {
\r
184 if (other.description != null) {
\r
187 } else if (!description.equals(other.description)) {
\r
190 if (name == null) {
\r
191 if (other.name != null) {
\r
194 } else if (!name.equals(other.name)) {
\r
197 if (path == null) {
\r
198 if (other.path != null) {
\r
201 } else if (!path.equals(other.path)) {
\r
204 if (reference == null) {
\r
205 if (other.reference != null) {
\r
208 } else if (!reference.equals(other.reference)) {
\r
211 if (units == null) {
\r
212 if (other.units != null) {
\r
215 } else if (!units.equals(other.units)) {
\r
222 public String toString() {
\r
223 StringBuilder builder = new StringBuilder();
\r
224 builder.append("BitsType [name=");
\r
225 builder.append(name);
\r
226 builder.append(", path=");
\r
227 builder.append(path);
\r
228 builder.append(", description=");
\r
229 builder.append(description);
\r
230 builder.append(", reference=");
\r
231 builder.append(reference);
\r
232 builder.append(", bits=");
\r
233 builder.append(bits);
\r
234 builder.append(", units=");
\r
235 builder.append(units);
\r
236 builder.append("]");
\r
237 return builder.toString();
\r