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;
15 * The binary built-in type represents any binary data, i.e., a sequence of
18 * Binary values are encoded with the base64 encoding scheme (see <a
19 * href="https://tools.ietf.org/html/rfc4648#section-4">[RFC4648], Section
21 * The canonical form of a binary value follows the rules in <a
22 * href="https://tools.ietf.org/html/rfc4648">[RFC4648]</a>.
25 * This interface was modeled according to definition in <a
26 * href="https://tools.ietf.org/html/rfc6020#section-9.8">[RFC-6020] The binary
29 public interface BinaryTypeDefinition extends LengthRestrictedTypeDefinition<BinaryTypeDefinition> {
31 static String toString(final @NonNull BinaryTypeDefinition type) {
32 return TypeDefinitions.toStringHelper(type).add("length", type.getLengthConstraint().orElse(null)).toString();
35 static int hashCode(final @NonNull BinaryTypeDefinition type) {
36 return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
37 type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getLengthConstraint().orElse(null));
40 static boolean equals(final @NonNull BinaryTypeDefinition type, final @Nullable Object obj) {
45 final BinaryTypeDefinition other = TypeDefinitions.castIfEquals(BinaryTypeDefinition.class, type, obj);
46 return other != null && type.getLengthConstraint().equals(other.getLengthConstraint());