8017109: Cleanup overrides warning in src/solaris/classes/sun/print/AttributeClass.java
authordxu
Thu, 15 Aug 2013 14:11:16 -0700
changeset 19419 67b5c7d91daa
parent 19418 bb4ae810197e
child 19420 a95fae98f735
8017109: Cleanup overrides warning in src/solaris/classes/sun/print/AttributeClass.java Reviewed-by: jgodinez
jdk/src/solaris/classes/sun/print/AttributeClass.java
--- a/jdk/src/solaris/classes/sun/print/AttributeClass.java	Thu Aug 15 12:36:50 2013 -0700
+++ b/jdk/src/solaris/classes/sun/print/AttributeClass.java	Thu Aug 15 14:11:16 2013 -0700
@@ -24,6 +24,7 @@
  */
 package sun.print;
 
+import java.util.Objects;
 import java.io.ByteArrayInputStream;
 
 public class AttributeClass {
@@ -248,11 +249,24 @@
         return myName;
     }
 
+    @Override
     public boolean equals(Object obj) {
-        return
-            obj != null &&
-            obj instanceof AttributeClass &&
-            obj.toString().equals (((AttributeClass) obj).toString());
+        if (!(obj instanceof AttributeClass)) {
+            return false;
+        }
+        if (this == obj) {
+            return true;
+        }
+
+        AttributeClass acObj = (AttributeClass) obj;
+        return myType == acObj.getType() &&
+               Objects.equals(myName, acObj.getName()) &&
+               Objects.equals(myValue, acObj.getObjectValue());
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(myType, myName, myValue);
     }
 
     public String toString() {