Merge branch 'master' of ../controller
[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
14 /**
15  * Contains methods for getting data from the <code>instance-identifier</code> YANG built-in type.
16  */
17 public interface InstanceIdentifierTypeDefinition
18         extends RequireInstanceRestrictedTypeDefinition<InstanceIdentifierTypeDefinition> {
19     static int hashCode(final @NonNull InstanceIdentifierTypeDefinition type) {
20         return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
21             type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.requireInstance());
22     }
23
24     static boolean equals(final @NonNull InstanceIdentifierTypeDefinition type, final @Nullable Object obj) {
25         if (type == obj) {
26             return true;
27         }
28
29         final InstanceIdentifierTypeDefinition other = TypeDefinitions.castIfEquals(
30             InstanceIdentifierTypeDefinition.class, type, obj);
31         return other != null && type.requireInstance() == other.requireInstance();
32     }
33
34     static String toString(final @NonNull InstanceIdentifierTypeDefinition type) {
35         return TypeDefinitions.toStringHelper(type).add("requireInstance", type.requireInstance()).toString();
36     }
37 }