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.BinaryTypeDefinition;
18 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
21 * The <code>default</code> implementation of Binary Type Definition interface.
23 * @see BinaryTypeDefinition
25 public final class BinaryType implements BinaryTypeDefinition {
26 private static final String DESCRIPTION = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
27 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.8";
28 private static final String UNITS = "";
30 private static final BinaryType INSTANCE = new BinaryType();
32 private final QName name = BaseTypes.BINARY_QNAME;
33 private final SchemaPath path = SchemaPath.create(Collections.singletonList(name), true);
34 private final List<Byte> bytes = Collections.emptyList();
35 private final List<LengthConstraint> lengthConstraints;
37 private BinaryType() {
38 this.lengthConstraints = Collections.singletonList(
39 BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
42 public static BinaryType getInstance() {
50 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
53 public BinaryTypeDefinition getBaseType() {
60 * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
63 public String getUnits() {
71 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
75 public Object getDefaultValue() {
82 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
85 public QName getQName() {
92 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
95 public SchemaPath getPath() {
103 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
106 public String getDescription() {
113 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
116 public String getReference() {
123 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
126 public Status getStatus() {
127 return Status.CURRENT;
134 * org.opendaylight.yangtools.yang.model.base.type.api.BinaryTypeDefinition
135 * #getLengthConstraint ()
138 public List<LengthConstraint> getLengthConstraints() {
139 return lengthConstraints;
143 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
144 return Collections.emptyList();
148 public int hashCode() {
149 final int prime = 31;
151 result = prime * result + ((bytes == null) ? 0 : bytes.hashCode());
152 result = prime * result + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
153 result = prime * result + ((name == null) ? 0 : name.hashCode());
154 result = prime * result + ((path == null) ? 0 : path.hashCode());
159 public boolean equals(final Object obj) {
166 if (getClass() != obj.getClass()) {
169 BinaryType other = (BinaryType) obj;
171 if (other.bytes != null) {
174 } else if (!bytes.equals(other.bytes)) {
177 if (lengthConstraints == null) {
178 if (other.lengthConstraints != null) {
181 } else if (!lengthConstraints.equals(other.lengthConstraints)) {
185 if (other.name != null) {
188 } else if (!name.equals(other.name)) {
192 if (other.path != null) {
195 } else if (!path.equals(other.path)) {
202 public String toString() {
203 StringBuilder builder = new StringBuilder();
204 builder.append("BinaryType [name=");
205 builder.append(name);
206 builder.append(", path=");
207 builder.append(path);
208 builder.append(", description=");
209 builder.append(DESCRIPTION);
210 builder.append(", reference=");
211 builder.append(REFERENCE);
212 builder.append(", bytes=");
213 builder.append(bytes);
214 builder.append(", lengthConstraints=");
215 builder.append(lengthConstraints);
216 builder.append(", units=");
217 builder.append(UNITS);
219 return builder.toString();