Package com.globalmentor.beans
Class AbstractGenericPropertyChangeListener<V>
- java.lang.Object
-
- com.globalmentor.beans.AbstractGenericPropertyChangeListener<V>
-
- Type Parameters:
V
- The type of property value.
- All Implemented Interfaces:
GenericPropertyChangeListener<V>
,java.beans.PropertyChangeListener
,java.util.EventListener
public abstract class AbstractGenericPropertyChangeListener<V> extends java.lang.Object implements GenericPropertyChangeListener<V>
A Java Beans property change listener retrofitted to use generics to cast to proper value type.- Author:
- Garret Wilson
-
-
Constructor Summary
Constructors Constructor Description AbstractGenericPropertyChangeListener()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> GenericPropertyChangeEvent<T>
getGenericPropertyChangeEvent(java.beans.PropertyChangeEvent propertyChangeEvent)
Converts a property change event to a generics-aware property value change event.void
propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
Called when a bound property is changed.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.globalmentor.beans.GenericPropertyChangeListener
propertyChange
-
-
-
-
Method Detail
-
propertyChange
public final void propertyChange(java.beans.PropertyChangeEvent propertyChangeEvent)
Called when a bound property is changed. This not-generics version calls the generic version, creating a new event if necessary. No checks are made at compile time to ensure the given event actually supports the given generic type.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- Parameters:
propertyChangeEvent
- An event object describing the event source, the property that has changed, and its old and new values.- See Also:
GenericPropertyChangeListener.propertyChange(GenericPropertyChangeEvent)
-
getGenericPropertyChangeEvent
public static <T> GenericPropertyChangeEvent<T> getGenericPropertyChangeEvent(java.beans.PropertyChangeEvent propertyChangeEvent)
Converts a property change event to a generics-aware property value change event. This is a utility method to facilitate creation of property value change listeners that cannot subclass this class. No checks are made at compile time to ensure the given event actually supports the given generic type.- Type Parameters:
T
- The type of property value.- Parameters:
propertyChangeEvent
- An event object describing the event source, the property that has changed, and its old and new values.- Returns:
- A generics-aware property change event, either cast from the provided object or created from the provided object's values as appropriate.
-
-