classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: javax.print.attribute.standard.Media equals fixlet


From: Wolfgang Baer
Subject: [cp-patches] FYI: javax.print.attribute.standard.Media equals fixlet
Date: Mon, 19 Dec 2005 11:57:19 +0100
User-agent: Debian Thunderbird 1.0.7 (X11/20051017)

Hi,

I am checking in the reimplementation of the equals method.


Marc, I can use your way with an additional null check if you
prefer ?


I think it is good to do it just in case one day in the future the will
be more subclasses. If that ever happens we will all have forgotten
about this little equals() method.

Cheers,

Mark

Regards,
Wolfgang

2005-12-19  Wolfgang Baer  <address@hidden>

        * javax/print/attribute/standard/Media.java (equals):
        Reimplemented to allow future subclasses to behave correctly.

Index: javax/print/attribute/standard/Media.java
===================================================================
RCS file: 
/cvsroot/classpath/classpath/javax/print/attribute/standard/Media.java,v
retrieving revision 1.5
diff -u -r1.5 Media.java
--- javax/print/attribute/standard/Media.java   16 Dec 2005 19:27:47 -0000      
1.5
+++ javax/print/attribute/standard/Media.java   19 Dec 2005 10:48:19 -0000
@@ -93,14 +93,11 @@
    */
   public boolean equals(Object obj)
   {
-    if ((obj instanceof MediaName && this instanceof MediaName)
-        || (obj instanceof MediaTray && this instanceof MediaTray)
-        || (obj instanceof MediaSizeName && this instanceof MediaSizeName))
-      {
-        return ((Media) obj).getValue() == this.getValue();
-      }
+    if (obj == null)
+      return false;
     
-    return false;
+    return (obj.getClass() == this.getClass()
+            && ((Media) obj).getValue() == this.getValue());      
   }
 
   /**

reply via email to

[Prev in Thread] Current Thread [Next in Thread]