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.ExtensionDefinition;
\r
17 import org.opendaylight.controller.yang.model.api.SchemaPath;
\r
18 import org.opendaylight.controller.yang.model.api.Status;
\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 LengthConstraint lengthConstraint;
\r
29 private String units = "";
\r
31 public BinaryType() {
\r
34 lengthConstraint = BaseConstraints.lengthConstraint(0L, Long.MAX_VALUE,
\r
36 bytes = Collections.emptyList();
\r
37 bytes = Collections.unmodifiableList(bytes);
\r
40 public BinaryType(final List<Byte> bytes,
\r
41 final LengthConstraint lengthConstraint, final String units) {
\r
44 this.lengthConstraint = lengthConstraint;
\r
51 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()
\r
54 public BinaryTypeDefinition getBaseType() {
\r
61 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()
\r
64 public String getUnits() {
\r
71 * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()
\r
74 public Object getDefaultValue() {
\r
81 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()
\r
84 public QName getQName() {
\r
91 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()
\r
94 public SchemaPath getPath() {
\r
101 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()
\r
104 public String getDescription() {
\r
105 return description;
\r
111 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()
\r
114 public String getReference() {
\r
121 * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()
\r
124 public Status getStatus() {
\r
125 return Status.CURRENT;
\r
132 * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition#getLengthConstraint
\r
136 public LengthConstraint getLengthConstraint() {
\r
137 return lengthConstraint;
\r
141 public List<ExtensionDefinition> getExtensionSchemaNodes() {
\r
142 return Collections.emptyList();
\r
146 public int hashCode() {
\r
147 final int prime = 31;
\r
149 result = prime * result + ((bytes == null) ? 0 : bytes.hashCode());
\r
150 result = prime * result
\r
151 + ((description == null) ? 0 : description.hashCode());
\r
154 + ((lengthConstraint == null) ? 0 : lengthConstraint.hashCode());
\r
155 result = prime * result + ((name == null) ? 0 : name.hashCode());
\r
156 result = prime * result + ((path == null) ? 0 : path.hashCode());
\r
157 result = prime * result
\r
158 + ((reference == null) ? 0 : reference.hashCode());
\r
159 result = prime * result + ((units == null) ? 0 : units.hashCode());
\r
164 public boolean equals(Object obj) {
\r
171 if (getClass() != obj.getClass()) {
\r
174 BinaryType other = (BinaryType) obj;
\r
175 if (bytes == null) {
\r
176 if (other.bytes != null) {
\r
179 } else if (!bytes.equals(other.bytes)) {
\r
182 if (description == null) {
\r
183 if (other.description != null) {
\r
186 } else if (!description.equals(other.description)) {
\r
189 if (lengthConstraint == null) {
\r
190 if (other.lengthConstraint != null) {
\r
193 } else if (!lengthConstraint.equals(other.lengthConstraint)) {
\r
196 if (name == null) {
\r
197 if (other.name != null) {
\r
200 } else if (!name.equals(other.name)) {
\r
203 if (path == null) {
\r
204 if (other.path != null) {
\r
207 } else if (!path.equals(other.path)) {
\r
210 if (reference == null) {
\r
211 if (other.reference != null) {
\r
214 } else if (!reference.equals(other.reference)) {
\r
217 if (units == null) {
\r
218 if (other.units != null) {
\r
221 } else if (!units.equals(other.units)) {
\r
228 public String toString() {
\r
229 StringBuilder builder = new StringBuilder();
\r
230 builder.append("BinaryType [name=");
\r
231 builder.append(name);
\r
232 builder.append(", path=");
\r
233 builder.append(path);
\r
234 builder.append(", description=");
\r
235 builder.append(description);
\r
236 builder.append(", reference=");
\r
237 builder.append(reference);
\r
238 builder.append(", bytes=");
\r
239 builder.append(bytes);
\r
240 builder.append(", lengthConstraint=");
\r
241 builder.append(lengthConstraint);
\r
242 builder.append(", units=");
\r
243 builder.append(units);
\r
244 builder.append("]");
\r
245 return builder.toString();
\r