Package jmri.beans
Class PropertyChangeSupport
java.lang.Object
jmri.beans.PropertyChangeSupport
- All Implemented Interfaces:
PropertyChangeFirer,PropertyChangeProvider
- Direct Known Subclasses:
AbstractPowerManager,AbstractProgrammer,AbstractThrottle,Action,Automation,AutomationItem,AutomationManager,BackupBase,DefaultProgrammerManager,DeferringProgrammerManager,Division,DivisionManager,LncvDevicesManager,LnOpsModeProgrammer,Lnsv1DevicesManager,Location,LocationManager,LocoIOData,ProgDebugger,RollingStock,RollingStockAttribute,RollingStockGroup,RollingStockGroupManager,RollingStockManager,Route,RouteLocation,RouteManager,Schedule,ScheduleItem,ScheduleManager,Setup,Track,Train,TrainManager,TrainSchedule,TrainScheduleManager,TurnoutOperation,VetoableChangeSupport
@ThreadSafe
public class PropertyChangeSupport
extends Object
implements PropertyChangeProvider, PropertyChangeFirer
Implementation of
PropertyChangeSupport that can be
extended by classes that would normally need to implement the methods of
PropertyChangeSupport independently.
This class is designed to support retrofitting an existing class with the
PropertyChangeProvider and PropertyChangeFirer interfaces without introducing
the complexity of the other implementations of PropertyChangeProvider in this
package. When designing new classes, it would be preferable to subclass
ArbitraryBean, Bean, or ConstrainedBean depending on
the design requirements of the new class.
This class is thread safe.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final PropertyChangeSupportProvide aPropertyChangeSupporthelper. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd aPropertyChangeListenerto the listener list.voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener) Add aPropertyChangeListenerfor a specific property.voidfireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue) Fire an indexed property change.voidfireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue) Fire an indexed property change.voidfireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) Fire an indexed property change.voidFire a property change.voidfirePropertyChange(String propertyName, boolean oldValue, boolean newValue) Fire a property change.voidfirePropertyChange(String propertyName, int oldValue, int newValue) Fire a property change.voidfirePropertyChange(String propertyName, Object oldValue, Object newValue) Fire a property change.Get allPropertyChangeListeners currently attached to this object.getPropertyChangeListeners(String propertyName) Get allPropertyChangeListeners currently listening to changes to the specified property.voidRemove the specified listener from this object.voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener) Remove the specified listener of the specified property from this object.
-
Field Details
-
propertyChangeSupport
Provide aPropertyChangeSupporthelper.
-
-
Constructor Details
-
PropertyChangeSupport
public PropertyChangeSupport()
-
-
Method Details
-
addPropertyChangeListener
Add aPropertyChangeListenerto the listener list.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- The PropertyChangeListener to be added
-
addPropertyChangeListener
public void addPropertyChangeListener(@CheckForNull String propertyName, @CheckForNull PropertyChangeListener listener) Add aPropertyChangeListenerfor a specific property.- Specified by:
addPropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to listen on.listener- The PropertyChangeListener to be added
-
getPropertyChangeListeners
Get allPropertyChangeListeners currently attached to this object.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
Get allPropertyChangeListeners currently listening to changes to the specified property.- Specified by:
getPropertyChangeListenersin interfacePropertyChangeProvider- Parameters:
propertyName- the name of the property of interest- Returns:
- an array of PropertyChangeListeners
-
removePropertyChangeListener
Remove the specified listener from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
listener- ThePropertyChangeListenerto remove.
-
removePropertyChangeListener
public void removePropertyChangeListener(@CheckForNull String propertyName, @CheckForNull PropertyChangeListener listener) Remove the specified listener of the specified property from this object.- Specified by:
removePropertyChangeListenerin interfacePropertyChangeProvider- Parameters:
propertyName- The name of the property to stop listening to.listener- ThePropertyChangeListenerto remove.
-
fireIndexedPropertyChange
public void fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue) Fire an indexed property change.- Specified by:
fireIndexedPropertyChangein interfacePropertyChangeFirer- Parameters:
propertyName- the programmatic name of the property that was changedindex- the index of the property element that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
fireIndexedPropertyChange
Fire an indexed property change.- Specified by:
fireIndexedPropertyChangein interfacePropertyChangeFirer- Parameters:
propertyName- the programmatic name of the property that was changedindex- the index of the property element that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
fireIndexedPropertyChange
public void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue) Fire an indexed property change.- Specified by:
fireIndexedPropertyChangein interfacePropertyChangeFirer- Parameters:
propertyName- the programmatic name of the property that was changedindex- the index of the property element that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
firePropertyChange
Fire a property change.- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Parameters:
propertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
firePropertyChange
Fire a property change.- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Parameters:
event- the PropertyChangeEvent to be fired
-
firePropertyChange
Fire a property change.- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Parameters:
propertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
firePropertyChange
Fire a property change.- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Parameters:
propertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-