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 com.google.common.base.Optional;
11 import java.util.Collections;
12 import java.util.List;
13 import java.util.Objects;
14 import org.opendaylight.yangtools.yang.common.QName;
15 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
16 import org.opendaylight.yangtools.yang.model.api.Status;
17 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
19 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
22 * The <code>default</code> implementation of Binary Type Definition interface.
24 * @see BinaryTypeDefinition
26 public final class BinaryType implements BinaryTypeDefinition {
27 private static final String DESCRIPTION = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
28 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.8";
29 private static final String UNITS = "";
31 private static final QName QNAME = BaseTypes.BINARY_QNAME;
33 private static final BinaryType INSTANCE = new BinaryType();
35 private static final SchemaPath PATH = SchemaPath.create(Collections.singletonList(QNAME), true);
36 private final List<Byte> bytes = Collections.emptyList();
37 private final List<LengthConstraint> lengthConstraints;
39 private BinaryType() {
40 this.lengthConstraints = Collections.singletonList(
41 BaseConstraints.newLengthConstraint(0, Long.MAX_VALUE, Optional.of(""), Optional.of("")));
44 public static BinaryType getInstance() {
52 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
55 public BinaryTypeDefinition getBaseType() {
62 * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
65 public String getUnits() {
73 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
77 public Object getDefaultValue() {
84 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
87 public QName getQName() {
94 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
97 public SchemaPath getPath() {
105 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
108 public String getDescription() {
115 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
118 public String getReference() {
125 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
128 public Status getStatus() {
129 return Status.CURRENT;
136 * org.opendaylight.yangtools.yang.model.base.type.api.BinaryTypeDefinition
137 * #getLengthConstraint ()
140 public List<LengthConstraint> getLengthConstraints() {
141 return lengthConstraints;
145 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
146 return Collections.emptyList();
150 public int hashCode() {
151 final int prime = 31;
153 result = prime * result + Objects.hashCode(bytes);
154 result = prime * result + Objects.hashCode(lengthConstraints);
155 result = prime * result + QNAME.hashCode();
156 result = prime * result + PATH.hashCode();
161 public boolean equals(final Object obj) {
168 if (getClass() != obj.getClass()) {
171 BinaryType other = (BinaryType) obj;
173 if (other.bytes != null) {
176 } else if (!bytes.equals(other.bytes)) {
179 if (lengthConstraints == null) {
180 if (other.lengthConstraints != null) {
183 } else if (!lengthConstraints.equals(other.lengthConstraints)) {
190 public String toString() {
191 StringBuilder builder = new StringBuilder();
192 builder.append("BinaryType [name=");
193 builder.append(QNAME);
194 builder.append(", description=");
195 builder.append(DESCRIPTION);
196 builder.append(", reference=");
197 builder.append(REFERENCE);
198 builder.append(", bytes=");
199 builder.append(bytes);
200 builder.append(", lengthConstraints=");
201 builder.append(lengthConstraints);
202 builder.append(", units=");
203 builder.append(UNITS);
205 return builder.toString();