Migrate yang.model.api.type to JDT annotations
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / type / IdentityrefTypeDefinition.java
index 4631e1db01525ff28c6bf32d24d3714c35340620..643030f8584e5c1b68538591146ab524cdd0b4e6 100644 (file)
@@ -7,23 +7,41 @@
  */
 package org.opendaylight.yangtools.yang.model.api.type;
 
-import org.opendaylight.yangtools.yang.common.QName;
+import java.util.Objects;
+import java.util.Set;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 /**
- * 
- * Contains method for getting data from <code>identityref</code> built-in YANG
- * type.
- * 
+ * Contains method for getting data from <code>identityref</code> built-in YANG type.
  */
 public interface IdentityrefTypeDefinition extends TypeDefinition<IdentityrefTypeDefinition> {
-
     /**
-     * Returns QName of the identity to which the instance of this type refers.
-     * 
-     * @return QName of referenced identity which is specified with the
-     *         <code>identity</code> YANG statement
+     * Returns the set of identities this reference points to.
+     *
+     * @return set of identities to which the instance of this type refers (in YANG 1.1 models) or a set containing
+     *         just one identity (in YANG 1.0 models)
      */
-    public QName getIdentity();
+    @NonNull Set<IdentitySchemaNode> getIdentities();
+
+    static int hashCode(final @NonNull IdentityrefTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
+            type.getUnits().orElse(null), type.getDefaultValue().orElse(null), type.getIdentities());
+    }
+
+    static boolean equals(final @NonNull IdentityrefTypeDefinition type, final @Nullable Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final IdentityrefTypeDefinition other = TypeDefinitions.castIfEquals(IdentityrefTypeDefinition.class, type,
+            obj);
+        return other != null && type.getIdentities().equals(other.getIdentities());
+    }
 
+    static String toString(final @NonNull IdentityrefTypeDefinition type) {
+        return TypeDefinitions.toStringHelper(type).add("identities", type.getIdentities()).toString();
+    }
 }