changeset 19419:67b5c7d91daa

8017109: Cleanup overrides warning in src/solaris/classes/sun/print/AttributeClass.java Reviewed-by: jgodinez
author dxu
date Thu, 15 Aug 2013 14:11:16 -0700
parents bb4ae810197e
children a95fae98f735
files jdk/src/solaris/classes/sun/print/AttributeClass.java
diffstat 1 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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() {