An example for a condition where the identity check ==
is required and the #equals
test fails is class {@link DisplayProject.binding.list.SelectionInList}. If the contained ListModel
changes its value, an internal listener is removed from the old value and added to the new value. The listener must be moved from the old instance to the new instance even if these are equal. The PropertyChangeSupport
doesn't fire a property change event if such a ListModel
is implemented as a {@link java.util.List}. This is because instances of List
are equal if and only if all list members are equal and if they are in the same sequence.
This class provides two means to fire an event if the old and new value are equal but not the same. First, you enable the identity check in constructor {@link #ExtendedPropertyChangeSupport(Object,boolean)}. By default all calls to #firePropertyChange
will then check the identity, not the equality. Second, you can invoke {@link #firePropertyChange(PropertyChangeEvent,boolean)} or{@link #firePropertyChange(String,Object,Object,boolean)} andenable or disable the identity check for this call only.
when adding a listener for a specific property.
property names when firing a named property change.
are performed in the event dispatch thread. In case a bean is changed in a thread other than the event dispatch thread, such a feature would help complying with Swing's single thread rule.
if 'checkIdentity' is true but the value types can be compared safely via #equals, for example Strings, Booleans and Numbers. @author Mattias Neuling @author Karsten Lentzsch @version $Revision: 1.9 $ @see PropertyChangeSupport @see PropertyChangeEvent @see PropertyChangeListener @see Object#equals(Object) @see java.util.List#equals(Object) Copyright (c) 2002-2005 JGoodies Karsten Lentzsch. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: o Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. o Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. o Neither the name of JGoodies Karsten Lentzsch nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|