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.api.type;
10 import java.util.Objects;
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.yangtools.yang.common.QName;
14 import org.opendaylight.yangtools.yang.common.YangConstants;
17 * The binary built-in type represents any binary data, i.e., a sequence of octets. Binary values are encoded with the
18 * Base64 encoding scheme (see <a href="https://tools.ietf.org/html/rfc4648#section-4">[RFC4648], Section 4</a>).<br>
19 * The canonical form of a binary value follows the rules defined in
20 * <a href="https://tools.ietf.org/html/rfc4648">[RFC4648]</a>.
23 * This interface was modeled according to definition in
24 * <a href="https://tools.ietf.org/html/rfc6020#section-9.8">[RFC-6020] The binary Built-In Type</a>
26 public interface BinaryTypeDefinition extends LengthRestrictedTypeDefinition<BinaryTypeDefinition> {
28 * Well-known QName of the {@code binary} built-in type.
30 QName QNAME = QName.create(YangConstants.RFC6020_YANG_MODULE, "binary").intern();
32 static String toString(final @NonNull BinaryTypeDefinition type) {
33 return TypeDefinitions.toStringHelper(type).add("length", type.getLengthConstraint().orElse(null)).toString();
36 static int hashCode(final @NonNull BinaryTypeDefinition type) {
37 return Objects.hash(type.getQName(), type.getUnknownSchemaNodes(), type.getBaseType(),
38 type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getLengthConstraint().orElse(null));
41 static boolean equals(final @NonNull BinaryTypeDefinition type, final @Nullable Object obj) {
46 final BinaryTypeDefinition other = TypeDefinitions.castIfEquals(BinaryTypeDefinition.class, type, obj);
47 return other != null && type.getLengthConstraint().equals(other.getLengthConstraint());