classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] FYI: java.beans 1.5 updates - small fix


From: Robert Schuster
Subject: [cp-patches] FYI: java.beans 1.5 updates - small fix
Date: Wed, 30 Nov 2005 12:25:24 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.12) Gecko/20051005

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all, hi Tom.

I checked this in:

2005-11-30  Robert Schuster  <address@hidden>

        * java/beans/PropertyChangeSupport.java:
        (fireIndexedPropertyChange): Removed argument checking.

Tom Tromey wrote:
> I'm checking this in.
> 
> +  public void fireIndexedPropertyChange(String name, int index,
> +                                        Object oldValue, Object newValue)
> +  {
> +    // FIXME: should we use equals() here?
> +    if (oldValue == newValue && oldValue != null)
> +      firePropertyChange(new IndexedPropertyChangeEvent(source, name,
> +                                                        oldValue, newValue,
> +                                                        index));
> +  }
At first the check is not necessary because it is done in firePropertyChange.
And the '==' must be a typo here. You only fire the event when the objects are
equal and are non-null ...).

It is important to give the objects the chance to make their own equality test.

The first line in firePropertyChange(PropertyChangeEvent) does that in a very
nice way:

if (event.oldValue != null && event.oldValue.equals(event.newValue))
      return;

cya
Robert
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDjYwkG9cfwmwwEtoRAnOjAJ9viysessPhVIDF+c2VHu7Nr3+WogCfQ6v8
AmG8cS1palTVKOZW7CjhN0k=
=8QWs
-----END PGP SIGNATURE-----
Index: java/beans/PropertyChangeSupport.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/beans/PropertyChangeSupport.java,v
retrieving revision 1.12
diff -u -r1.12 PropertyChangeSupport.java
--- java/beans/PropertyChangeSupport.java       27 Nov 2005 14:57:19 -0000      
1.12
+++ java/beans/PropertyChangeSupport.java       30 Nov 2005 11:17:04 -0000
@@ -408,11 +408,9 @@
   public void fireIndexedPropertyChange(String name, int index,
                                         Object oldValue, Object newValue)
   {
-    // FIXME: should we use equals() here?
-    if (oldValue == newValue && oldValue != null)
+      // Argument checking is done in firePropertyChange(PropertyChangeEvent) .
       firePropertyChange(new IndexedPropertyChangeEvent(source, name,
                                                         oldValue, newValue,
-                                                        index));
   }
 
   /**

reply via email to

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