Class 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 Detail

      • AbstractGenericPropertyChangeListener

        public AbstractGenericPropertyChangeListener()
    • 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 interface java.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.