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;
20 import com.google.common.base.Optional;
23 * The <code>default</code> implementation of Binary Type Definition interface.
25 * @see BinaryTypeDefinition
27 public final class BinaryType implements BinaryTypeDefinition {
28 private static final String DESCRIPTION = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
29 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.8";
30 private static final String UNITS = "";
32 private final static QName QNAME = BaseTypes.BINARY_QNAME;
34 private static final BinaryType INSTANCE = new BinaryType();
36 private final static SchemaPath PATH = SchemaPath.create(Collections.singletonList(QNAME), true);
37 private final List<Byte> bytes = Collections.emptyList();
38 private final List<LengthConstraint> lengthConstraints;
40 private BinaryType() {
41 this.lengthConstraints = Collections.singletonList(
42 BaseConstraints.newLengthConstraint(0, Long.MAX_VALUE, Optional.of(""), Optional.of("")));
45 public static BinaryType getInstance() {
53 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
56 public BinaryTypeDefinition getBaseType() {
63 * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
66 public String getUnits() {
74 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
78 public Object getDefaultValue() {
85 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
88 public QName getQName() {
95 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
98 public SchemaPath getPath() {
106 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
109 public String getDescription() {
116 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
119 public String getReference() {
126 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
129 public Status getStatus() {
130 return Status.CURRENT;
137 * org.opendaylight.yangtools.yang.model.base.type.api.BinaryTypeDefinition
138 * #getLengthConstraint ()
141 public List<LengthConstraint> getLengthConstraints() {
142 return lengthConstraints;
146 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
147 return Collections.emptyList();
151 public int hashCode() {
152 final int prime = 31;
154 result = prime * result + ((bytes == null) ? 0 : bytes.hashCode());
155 result = prime * result + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
156 result = prime * result + QNAME.hashCode();
157 result = prime * result + PATH.hashCode();
162 public boolean equals(final Object obj) {
169 if (getClass() != obj.getClass()) {
172 BinaryType other = (BinaryType) obj;
174 if (other.bytes != null) {
177 } else if (!bytes.equals(other.bytes)) {
180 if (lengthConstraints == null) {
181 if (other.lengthConstraints != null) {
184 } else if (!lengthConstraints.equals(other.lengthConstraints)) {
191 public String toString() {
192 StringBuilder builder = new StringBuilder();
193 builder.append("BinaryType [name=");
194 builder.append(QNAME);
195 builder.append(", description=");
196 builder.append(DESCRIPTION);
197 builder.append(", reference=");
198 builder.append(REFERENCE);
199 builder.append(", bytes=");
200 builder.append(bytes);
201 builder.append(", lengthConstraints=");
202 builder.append(lengthConstraints);
203 builder.append(", units=");
204 builder.append(UNITS);
206 return builder.toString();