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
,DefaultProgrammerManager
,DeferringProgrammerManager
,Division
,DivisionManager
,LncvDevicesManager
,LnOpsModeProgrammer
,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 java.lang.Object implements PropertyChangeProvider, PropertyChangeFirer
Implementation ofPropertyChangeSupport
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
, orConstrainedBean
depending on the design requirements of the new class.This class is thread safe.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.beans.PropertyChangeSupport
propertyChangeSupport
Provide aPropertyChangeSupport
helper.
-
Constructor Summary
Constructors Constructor Description PropertyChangeSupport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add aPropertyChangeListener
to the listener list.void
addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Add aPropertyChangeListener
for a specific property.void
fireIndexedPropertyChange(java.lang.String propertyName, int index, boolean oldValue, boolean newValue)
Fire an indexed property change.void
fireIndexedPropertyChange(java.lang.String propertyName, int index, int oldValue, int newValue)
Fire an indexed property change.void
fireIndexedPropertyChange(java.lang.String propertyName, int index, java.lang.Object oldValue, java.lang.Object newValue)
Fire an indexed property change.void
firePropertyChange(java.beans.PropertyChangeEvent event)
Fire a property change.void
firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
Fire a property change.void
firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
Fire a property change.void
firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Fire a property change.java.beans.PropertyChangeListener[]
getPropertyChangeListeners()
Get allPropertyChangeListener
s currently attached to this object.java.beans.PropertyChangeListener[]
getPropertyChangeListeners(java.lang.String propertyName)
Get allPropertyChangeListener
s currently listening to changes to the specified property.void
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove the specified listener from this object.void
removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
Remove the specified listener of the specified property from this object.
-
-
-
Field Detail
-
propertyChangeSupport
protected final java.beans.PropertyChangeSupport propertyChangeSupport
Provide aPropertyChangeSupport
helper.
-
-
Constructor Detail
-
PropertyChangeSupport
public PropertyChangeSupport()
-
-
Method Detail
-
addPropertyChangeListener
public void addPropertyChangeListener(@CheckForNull java.beans.PropertyChangeListener listener)
Add aPropertyChangeListener
to the listener list.- Specified by:
addPropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
listener
- The PropertyChangeListener to be added
-
addPropertyChangeListener
public void addPropertyChangeListener(@CheckForNull java.lang.String propertyName, @CheckForNull java.beans.PropertyChangeListener listener)
Add aPropertyChangeListener
for a specific property.- Specified by:
addPropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
propertyName
- The name of the property to listen on.listener
- The PropertyChangeListener to be added
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
Get allPropertyChangeListener
s currently attached to this object.- Specified by:
getPropertyChangeListeners
in interfacePropertyChangeProvider
- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(@CheckForNull java.lang.String propertyName)
Get allPropertyChangeListener
s currently listening to changes to the specified property.- Specified by:
getPropertyChangeListeners
in interfacePropertyChangeProvider
- Parameters:
propertyName
- the name of the property of interest- Returns:
- an array of PropertyChangeListeners
-
removePropertyChangeListener
public void removePropertyChangeListener(@CheckForNull java.beans.PropertyChangeListener listener)
Remove the specified listener from this object.- Specified by:
removePropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
listener
- ThePropertyChangeListener
to remove.
-
removePropertyChangeListener
public void removePropertyChangeListener(@CheckForNull java.lang.String propertyName, @CheckForNull java.beans.PropertyChangeListener listener)
Remove the specified listener of the specified property from this object.- Specified by:
removePropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
propertyName
- The name of the property to stop listening to.listener
- ThePropertyChangeListener
to remove.
-
fireIndexedPropertyChange
public void fireIndexedPropertyChange(java.lang.String propertyName, int index, boolean oldValue, boolean newValue)
Fire an indexed property change.- Specified by:
fireIndexedPropertyChange
in 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(java.lang.String propertyName, int index, int oldValue, int newValue)
Fire an indexed property change.- Specified by:
fireIndexedPropertyChange
in 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(java.lang.String propertyName, int index, java.lang.Object oldValue, java.lang.Object newValue)
Fire an indexed property change.- Specified by:
fireIndexedPropertyChange
in 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
public void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
Fire a property change.- Specified by:
firePropertyChange
in 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
public void firePropertyChange(java.beans.PropertyChangeEvent event)
Fire a property change.- Specified by:
firePropertyChange
in interfacePropertyChangeFirer
- Parameters:
event
- the PropertyChangeEvent to be fired
-
firePropertyChange
public void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
Fire a property change.- Specified by:
firePropertyChange
in 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
public void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Fire a property change.- Specified by:
firePropertyChange
in interfacePropertyChangeFirer
- Parameters:
propertyName
- the programmatic name of the property that was changedoldValue
- the old value of the propertynewValue
- the new value of the property
-
-