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
,LncvDevicesManager
,LnOpsModeProgrammer
,Location
,LocationManager
,LocoIOData
,ProgDebugger
,RollingStock
,RollingStockAttribute
,RollingStockGroup
,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
Fields Modifier and Type Field Description protected PropertyChangeSupport
propertyChangeSupport
Provide aPropertyChangeSupport
helper. -
Constructor Summary
Constructors Constructor Description PropertyChangeSupport()
-
Method Summary
Modifier and Type Method Description void
addPropertyChangeListener(PropertyChangeListener listener)
Add aPropertyChangeListener
to the listener list.void
addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
Add aPropertyChangeListener
for a specific property.void
fireIndexedPropertyChange(String propertyName, int index, boolean oldValue, boolean newValue)
Fire an indexed property change.void
fireIndexedPropertyChange(String propertyName, int index, int oldValue, int newValue)
Fire an indexed property change.void
fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)
Fire an indexed property change.void
firePropertyChange(PropertyChangeEvent event)
Fire a property change.void
firePropertyChange(String propertyName, boolean oldValue, boolean newValue)
Fire a property change.void
firePropertyChange(String propertyName, int oldValue, int newValue)
Fire a property change.void
firePropertyChange(String propertyName, Object oldValue, Object newValue)
Fire a property change.PropertyChangeListener[]
getPropertyChangeListeners()
Get allPropertyChangeListener
s currently attached to this object.PropertyChangeListener[]
getPropertyChangeListeners(String propertyName)
Get allPropertyChangeListener
s currently listening to changes to the specified property.void
removePropertyChangeListener(PropertyChangeListener listener)
Remove the specified listener from this object.void
removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
Remove the specified listener of the specified property from this object.
-
Field Details
-
propertyChangeSupport
Provide aPropertyChangeSupport
helper.
-
-
Constructor Details
-
Method Details
-
addPropertyChangeListener
Add aPropertyChangeListener
to the listener list.- Specified by:
addPropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
listener
- The PropertyChangeListener to be added
-
addPropertyChangeListener
public void addPropertyChangeListener(@CheckForNull String propertyName, @CheckForNull 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
Get allPropertyChangeListener
s currently attached to this object.- Specified by:
getPropertyChangeListeners
in interfacePropertyChangeProvider
- Returns:
- An array of PropertyChangeListeners.
-
getPropertyChangeListeners
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
Remove the specified listener from this object.- Specified by:
removePropertyChangeListener
in interfacePropertyChangeProvider
- Parameters:
listener
- ThePropertyChangeListener
to remove.
-
removePropertyChangeListener
public void removePropertyChangeListener(@CheckForNull String propertyName, @CheckForNull 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(String propertyName, int index, boolean oldValue, boolean newValue)Fire an indexed property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.- 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
Fire an indexed property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.- 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(String propertyName, int index, Object oldValue, Object newValue)Fire an indexed property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.- 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
Fire a property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.- 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
Fire a property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.- Specified by:
firePropertyChange
in interfacePropertyChangeFirer
- Parameters:
event
- the PropertyChangeEvent to be fired
-
firePropertyChange
Fire a property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.- 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
Fire a property change. Despite being public due to limitations in Java 8, this method should only be called by the subclasses of implementing classes, as this will become a protected class when JMRI requires Java 11 or newer.- 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
-