Remove yang.model.util.BaseTypes
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / type / InstanceIdentifierTypeDefinition.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.api.type;
9
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;
15
16 /**
17  * Contains methods for getting data from the <code>instance-identifier</code> YANG built-in type.
18  */
19 public interface InstanceIdentifierTypeDefinition
20         extends RequireInstanceRestrictedTypeDefinition<InstanceIdentifierTypeDefinition> {
21     /**
22      * Well-known QName of the {@code instance-identifier} built-in type.
23      */
24     QName QNAME = QName.create(YangConstants.RFC6020_YANG_MODULE, "instance-identifier").intern();
25
26     static int hashCode(final @NonNull InstanceIdentifierTypeDefinition type) {
27         return Objects.hash(type.getQName(), type.getUnknownSchemaNodes(), type.getBaseType(),
28             type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.requireInstance());
29     }
30
31     static boolean equals(final @NonNull InstanceIdentifierTypeDefinition type, final @Nullable Object obj) {
32         if (type == obj) {
33             return true;
34         }
35
36         final InstanceIdentifierTypeDefinition other = TypeDefinitions.castIfEquals(
37             InstanceIdentifierTypeDefinition.class, type, obj);
38         return other != null && type.requireInstance() == other.requireInstance();
39     }
40
41     static String toString(final @NonNull InstanceIdentifierTypeDefinition type) {
42         return TypeDefinitions.toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
43     }
44 }