Class GenericPropertyChangeEvent<V>

java.lang.Object
java.util.EventObject
java.beans.PropertyChangeEvent
com.globalmentor.beans.GenericPropertyChangeEvent<V>
Type Parameters:
V - The type of property value.
All Implemented Interfaces:
Event, TargetedEvent, Serializable

public class GenericPropertyChangeEvent<V> extends PropertyChangeEvent implements TargetedEvent
A property value change event is a Java Beans property change event retrofitted to use generics to cast to proper value type. This event is also targeted, specifying an event target which may or may not be the same as the source object firing this event.
Author:
Garret Wilson
See Also:
  • Constructor Details

    • GenericPropertyChangeEvent

      public GenericPropertyChangeEvent(Object source, String propertyName, V oldValue, V newValue)
      Source and property name constructor with old and new values. The target will be set to be the same as the given source.
      Parameters:
      source - The bean that fired the event.
      propertyName - The programmatic name of the property that was changed.
      oldValue - The old value of the property, or null if no old value is not available.
      newValue - The new value of the property, or null if the new value is not available.
    • GenericPropertyChangeEvent

      public GenericPropertyChangeEvent(Object source, Object target, String propertyName, V oldValue, V newValue)
      Source, target, and property name constructor with old and new values.
      Parameters:
      source - The bean that fired the event.
      target - The target of the event.
      propertyName - The programmatic name of the property that was changed.
      oldValue - The old value of the property, or null if no old value is not available.
      newValue - The new value of the property, or null if the new value is not available.
      Throws:
      NullPointerException - if the given source and/or target is null.
    • GenericPropertyChangeEvent

      public GenericPropertyChangeEvent(PropertyChangeEvent propertyChangeEvent)
      Property change event copy constructor. If the property change event is TargetedEvent, the target is copied from that event; otherwise, the event source will be used as the target.
      Parameters:
      propertyChangeEvent - A property change event the values of which will later cast to this class' generic type.
    • GenericPropertyChangeEvent

      public GenericPropertyChangeEvent(Object source, PropertyChangeEvent propertyChangeEvent)
      Property change event copy constructor that specifies a different source. If the property change event is TargetedEvent, the target is copied from that event; otherwise, the given source will be used as the target.
      Parameters:
      source - The object on which the event initially occurred.
      propertyChangeEvent - A property change event the values of which will later cast to this class' generic type.
      Throws:
      NullPointerException - if the given source is null.
  • Method Details

    • getTarget

      public Object getTarget()
      Returns the object to which the event applies. This may be a different than source, which is the object that generated this event instance.
      Specified by:
      getTarget in interface TargetedEvent
      Returns:
      The target of the event.
    • getOldValue

      public V getOldValue()
      Overrides:
      getOldValue in class PropertyChangeEvent
      Returns:
      The old value of the property, or null if the old value is not available.
    • getNewValue

      public V getNewValue()
      Overrides:
      getNewValue in class PropertyChangeEvent
      Returns:
      The new value of the property, or null if the new value is not available.