Package com.globalmentor.beans
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
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:
-
Field Summary
Fields inherited from class java.util.EventObject
source
-
Constructor Summary
ConstructorDescriptionGenericPropertyChangeEvent
(PropertyChangeEvent propertyChangeEvent) Property change event copy constructor.GenericPropertyChangeEvent
(Object source, PropertyChangeEvent propertyChangeEvent) Property change event copy constructor that specifies a different source.GenericPropertyChangeEvent
(Object source, Object target, String propertyName, V oldValue, V newValue) Source, target, and property name constructor with old and new values.GenericPropertyChangeEvent
(Object source, String propertyName, V oldValue, V newValue) Source and property name constructor with old and new values. -
Method Summary
Modifier and TypeMethodDescriptionReturns the object to which the event applies.Methods inherited from class java.beans.PropertyChangeEvent
getPropagationId, getPropertyName, setPropagationId, toString
Methods inherited from class java.util.EventObject
getSource
-
Constructor Details
-
GenericPropertyChangeEvent
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, ornull
if no old value is not available.newValue
- The new value of the property, ornull
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, ornull
if no old value is not available.newValue
- The new value of the property, ornull
if the new value is not available.- Throws:
NullPointerException
- if the given source and/or target isnull
.
-
GenericPropertyChangeEvent
Property change event copy constructor. If the property change event isTargetedEvent
, 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
Property change event copy constructor that specifies a different source. If the property change event isTargetedEvent
, 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 isnull
.
-
-
Method Details
-
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 interfaceTargetedEvent
- Returns:
- The target of the event.
-
getOldValue
- Overrides:
getOldValue
in classPropertyChangeEvent
- Returns:
- The old value of the property, or
null
if the old value is not available.
-
getNewValue
- Overrides:
getNewValue
in classPropertyChangeEvent
- Returns:
- The new value of the property, or
null
if the new value is not available.
-