TypeStatement takes a QName argument
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / api / type / EnumTypeDefinition.java
index 64a3fd2ac5321fb200d80196343dc1424146f255..05d4ac3f9df24e5e4406760151c0125ed8258fcd 100644 (file)
@@ -8,49 +8,61 @@
 package org.opendaylight.yangtools.yang.model.api.type;
 
 import java.util.List;
-
-import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import java.util.Objects;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 /**
- * 
- * Makes is possible to access to the individual enumeration values of this
- * type.
- * 
+ * Makes is possible to access to the individual enumeration values of this 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
+     * Contains the methods for accessing the data about the concrete enumeration item which represents {@code enum}
+     * YANG type.
      */
-    List<EnumPair> getValues();
-
-    /**
-     * 
-     * Contains the methods for accessing the data about the concrete
-     * enumeration item which represents <code>enum</code> YANG type.
-     */
-    interface EnumPair extends SchemaNode {
-
+    interface EnumPair extends DocumentedNode.WithStatus {
         /**
          * The name to specify each assigned name of an enumeration type.
-         * 
+         *
          * @return name of each assigned name of an enumeration type.
          */
-        public String getName();
+        String getName();
 
         /**
-         * The "value" statement, which is optional, is used to associate an
-         * integer value with the assigned name for the enum. This integer value
-         * MUST be in the range -2147483648 to 2147483647, and it MUST be unique
-         * within the enumeration type.
-         * 
+         * The "value" statement, which is optional, is used to associate an integer value with the assigned name
+         * for the enum. This integer value MUST be unique within the enumeration type.
+         *
          * @return integer value assigned to enumeration
          */
-        public Integer getValue();
+        int getValue();
+    }
+
+    /**
+     * Returns all enumeration values.
+     *
+     * @return list of {@code EnumPair} type instances which contain the data about all individual enumeration pairs
+     *         of {@code enumeration} YANG built-in type
+     */
+    @NonNull List<EnumPair> getValues();
+
+    static boolean equals(final @NonNull EnumTypeDefinition type, final @Nullable 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 @NonNull EnumTypeDefinition type) {
+        return Objects.hash(type.getQName(), type.getUnknownSchemaNodes(), type.getBaseType(),
+            type.getUnits().orElse(null),
+            type.getDefaultValue(), type.getValues());
+    }
+
+    static String toString(final @NonNull EnumTypeDefinition type) {
+        return TypeDefinitions.toStringHelper(type).add("values", type.getValues()).toString();
     }
 }