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.BinaryTypeDefinition;
\r
14 import org.opendaylight.controller.model.api.type.LengthConstraint;
\r
15 import org.opendaylight.controller.yang.common.QName;
\r
16 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
17 import org.opendaylight.controller.yang.model.api.Status;
\r
18 import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
\r
20 public class BinaryType implements BinaryTypeDefinition {
\r
22 private final QName name = BaseTypes.constructQName("binary");
\r
23 private final SchemaPath path = BaseTypes.schemaPath(name);
\r
24 private final String description = "";
\r
25 private final String reference = "";
\r
27 private List<Byte> bytes;
\r
28 private final List<LengthConstraint> lengthConstraints;
\r
29 private String units = "";
\r
31 public BinaryType() {
\r
34 lengthConstraints = Collections.emptyList();
\r
35 bytes = Collections.emptyList();
\r
36 bytes = Collections.unmodifiableList(bytes);
\r
39 public BinaryType(final List<Byte> bytes,
\r
40 final List<LengthConstraint> lengthConstraints, final String units) {
\r
43 this.lengthConstraints = lengthConstraints;
\r
50 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
53 public BinaryTypeDefinition getBaseType() {
\r
60 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
63 public String getUnits() {
\r
70 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
73 public Object getDefaultValue() {
\r
80 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
83 public QName getQName() {
\r
90 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
93 public SchemaPath getPath() {
\r
100 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
103 public String getDescription() {
\r
104 return description;
\r
110 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
113 public String getReference() {
\r
120 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
123 public Status getStatus() {
\r
124 return Status.CURRENT;
\r
131 * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition#getLengthConstraint
\r
135 public List<LengthConstraint> getLengthConstraints() {
\r
136 return lengthConstraints;
\r
140 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
\r
141 return Collections.emptyList();
\r
145 public int hashCode() {
\r
146 final int prime = 31;
\r
148 result = prime * result + ((bytes == null) ? 0 : bytes.hashCode());
\r
149 result = prime * result
\r
150 + ((description == null) ? 0 : description.hashCode());
\r
153 + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
\r
154 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
155 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
156 result = prime * result
\r
157 + ((reference == null) ? 0 : reference.hashCode());
\r
158 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
163 public boolean equals(Object obj) {
\r
170 if (getClass() != obj.getClass()) {
\r
173 BinaryType other = (BinaryType) obj;
\r
174 if (bytes == null) {
\r
175 if (other.bytes != null) {
\r
178 } else if (!bytes.equals(other.bytes)) {
\r
181 if (description == null) {
\r
182 if (other.description != null) {
\r
185 } else if (!description.equals(other.description)) {
\r
188 if (lengthConstraints == null) {
\r
189 if (other.lengthConstraints != null) {
\r
192 } else if (!lengthConstraints.equals(other.lengthConstraints)) {
\r
195 if (name == null) {
\r
196 if (other.name != null) {
\r
199 } else if (!name.equals(other.name)) {
\r
202 if (path == null) {
\r
203 if (other.path != null) {
\r
206 } else if (!path.equals(other.path)) {
\r
209 if (reference == null) {
\r
210 if (other.reference != null) {
\r
213 } else if (!reference.equals(other.reference)) {
\r
216 if (units == null) {
\r
217 if (other.units != null) {
\r
220 } else if (!units.equals(other.units)) {
\r
227 public String toString() {
\r
228 StringBuilder builder = new StringBuilder();
\r
229 builder.append("BinaryType [name=");
\r
230 builder.append(name);
\r
231 builder.append(", path=");
\r
232 builder.append(path);
\r
233 builder.append(", description=");
\r
234 builder.append(description);
\r
235 builder.append(", reference=");
\r
236 builder.append(reference);
\r
237 builder.append(", bytes=");
\r
238 builder.append(bytes);
\r
239 builder.append(", lengthConstraints=");
\r
240 builder.append(lengthConstraints);
\r
241 builder.append(", units=");
\r
242 builder.append(units);
\r
243 builder.append("]");
\r
244 return builder.toString();
\r