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
25 * @deprecated Use {@link org.opendaylight.yangtools.yang.model.util.type.BaseTypes#binaryType()} instead
28 public final class BinaryType implements BinaryTypeDefinition {
29 private static final String DESCRIPTION = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
30 private static final String REFERENCE = "https://tools.ietf.org/html/rfc6020#section-9.8";
31 private static final String UNITS = "";
33 private static final QName QNAME = BaseTypes.BINARY_QNAME;
35 private static final BinaryType INSTANCE = new BinaryType();
37 private static final SchemaPath PATH = SchemaPath.create(Collections.singletonList(QNAME), true);
38 private final List<Byte> bytes = Collections.emptyList();
39 private final List<LengthConstraint> lengthConstraints;
41 private BinaryType() {
42 this.lengthConstraints = Collections.singletonList(
43 BaseConstraints.newLengthConstraint(0, Long.MAX_VALUE, Optional.of(""), Optional.of("")));
46 public static BinaryType getInstance() {
54 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
57 public BinaryTypeDefinition getBaseType() {
64 * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getUnits()
67 public String getUnits() {
75 * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
79 public Object getDefaultValue() {
86 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getQName()
89 public QName getQName() {
96 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getPath()
99 public SchemaPath getPath() {
107 * org.opendaylight.yangtools.yang.model.api.SchemaNode#getDescription()
110 public String getDescription() {
117 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getReference()
120 public String getReference() {
127 * @see org.opendaylight.yangtools.yang.model.api.SchemaNode#getStatus()
130 public Status getStatus() {
131 return Status.CURRENT;
138 * org.opendaylight.yangtools.yang.model.base.type.api.BinaryTypeDefinition
139 * #getLengthConstraint ()
142 public List<LengthConstraint> getLengthConstraints() {
143 return lengthConstraints;
147 public List<UnknownSchemaNode> getUnknownSchemaNodes() {
148 return Collections.emptyList();
152 public int hashCode() {
153 final int prime = 31;
155 result = prime * result + Objects.hashCode(bytes);
156 result = prime * result + Objects.hashCode(lengthConstraints);
157 result = prime * result + QNAME.hashCode();
158 result = prime * result + PATH.hashCode();
163 public boolean equals(final Object obj) {
170 if (getClass() != obj.getClass()) {
173 BinaryType other = (BinaryType) obj;
174 return Objects.equals(bytes, other.bytes) && Objects.equals(lengthConstraints, other.lengthConstraints);
178 public String toString() {
179 StringBuilder builder = new StringBuilder();
180 builder.append("BinaryType [name=");
181 builder.append(QNAME);
182 builder.append(", description=");
183 builder.append(DESCRIPTION);
184 builder.append(", reference=");
185 builder.append(REFERENCE);
186 builder.append(", bytes=");
187 builder.append(bytes);
188 builder.append(", lengthConstraints=");
189 builder.append(lengthConstraints);
190 builder.append(", units=");
191 builder.append(UNITS);
193 return builder.toString();