Move TypeDefinitions into yang-model-api
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / type / EnumTypeDefinition.java
index 402d7135d9f8eb5be3ea0766d2873fddcf196e65..d8a47296934f079279075095bb282ed298ce04d9 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.api.type;
 
 import java.util.List;
+import java.util.Objects;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -17,15 +18,6 @@ import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
  * type.
  */
 public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
-    /**
-     * Returns all enumeration values.
-     *
-     * @return list of <code>EnumPair</code> type instastances which contain the
-     *         data about all individual enumeration pairs of
-     *         <code>enumeration</code> YANG built-in type
-     */
-    @Nonnull List<EnumPair> getValues();
-
     /**
      * Contains the methods for accessing the data about the concrete
      * enumeration item which represents <code>enum</code> YANG type.
@@ -47,4 +39,32 @@ public interface EnumTypeDefinition extends TypeDefinition<EnumTypeDefinition> {
          */
         int getValue();
     }
+
+    /**
+     * Returns all enumeration values.
+     *
+     * @return list of <code>EnumPair</code> type instastances which contain the
+     *         data about all individual enumeration pairs of
+     *         <code>enumeration</code> YANG built-in type
+     */
+    @Nonnull List<EnumPair> getValues();
+
+    static boolean equals(final EnumTypeDefinition type, final Object obj) {
+        if (type == obj) {
+            return true;
+        }
+
+        final EnumTypeDefinition other = TypeDefinitions.castIfEquals(EnumTypeDefinition.class, type, obj);
+        return other != null && type.getValues().equals(other.getValues());
+    }
+
+    static int hashCode(final EnumTypeDefinition type) {
+        return Objects.hash(type.getPath(), type.getUnknownSchemaNodes(), type.getBaseType(),
+            type.getUnits().orElse(null),
+            type.getDefaultValue(), type.getValues());
+    }
+
+    static String toString(final EnumTypeDefinition type) {
+        return TypeDefinitions.toStringHelper(type).add("values", type.getValues()).toString();
+    }
 }