de.caff.generics

## Class WeakPropertyChangeListener

- java.lang.Object
- - de.caff.generics.WeakPropertyChangeListener

- All Implemented Interfaces:
    java.beans.PropertyChangeListener, java.util.EventListener

      public class WeakPropertyChangeListener
      extends java.lang.Object
      implements java.beans.PropertyChangeListener

  Wrapper for a property change listener which reference the original change listener weakly.

  If the original listener is garbage collected, this property change listener is just doing nothing. Note that although the referenced listener and everything what is attached to it might be released, this listener is still attached to all classes it was added as a property change listener, because it has no chance to know where it was added, so it cannot remove itself.

  Author:
    Rammi

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WeakPropertyChangeListener(java.beans.PropertyChangeListener wrapped)` Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `isValid()` Is this listener still valid?
    `void` | `propertyChange(java.beans.PropertyChangeEvent evt)` This method gets called when a bound property is changed.
    `static void` | `removeWeakPropertyListener(java.beans.PropertyChangeSupport support, java.beans.PropertyChangeListener listener)` Remove a weak property change listener from a property change support.
    `static void` | `removeWeakPropertyListener(java.beans.PropertyChangeSupport support, java.lang.String propertyName, java.beans.PropertyChangeListener listener)` Remove a weak property change listener listening for a special property from a property change support.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### WeakPropertyChangeListener

          public WeakPropertyChangeListener(@NotNull
                                            java.beans.PropertyChangeListener wrapped)

      Constructor.
      Parameters:
        `wrapped` - listener to wrap, which is only hold via a weak reference

  - ### Method Detail

    - #### propertyChange

          public void propertyChange(java.beans.PropertyChangeEvent evt)

      This method gets called when a bound property is changed.
      Specified by:
        `propertyChange` in interface `java.beans.PropertyChangeListener`
      Parameters:
        `evt` - A PropertyChangeEvent object describing the event source and the property that has changed.

    - #### isValid

          public boolean isValid()

      Is this listener still valid?
      Returns:
        `true` if the reference is still available
        `false` if it is no longer available

    - #### removeWeakPropertyListener

          public static void removeWeakPropertyListener(@NotNull
                                                        java.beans.PropertyChangeSupport support,
                                                        @NotNull
                                                        java.beans.PropertyChangeListener listener)

      Remove a weak property change listener from a property change support. This will also remove all weak listeners where the reference is invalid.
      Parameters:
        `support` - property change support
        `listener` - original listener wrapped by the weak listener

    - #### removeWeakPropertyListener

          public static void removeWeakPropertyListener(@NotNull
                                                        java.beans.PropertyChangeSupport support,
                                                        @NotNull
                                                        java.lang.String propertyName,
                                                        @NotNull
                                                        java.beans.PropertyChangeListener listener)

      Remove a weak property change listener listening for a special property from a property change support. This will also remove all weak listeners where the reference is invalid.
      Parameters:
        `support` - property change support
        `propertyName` - property name
        `listener` - original listener wrapped by the weak listener