- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.util.NamedBeanExpectedValue<T,S>
-
- Type Parameters:
T
- the supported type of NamedBeanS
- the supported type of value
- All Implemented Interfaces:
BeanInterface
,PropertyChangeFirer
,PropertyChangeProvider
,ExpectedState<T,S>
- Direct Known Subclasses:
NamedBeanExpectedState
public class NamedBeanExpectedValue<T extends NamedBean,S> extends Bean implements ExpectedState<T,S>
Retain a NamedBean and its expected value (called a state in this class).Note the NamedBean is held in a
NamedBeanHandle
.
-
-
Field Summary
-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
Fields inherited from interface jmri.ExpectedState
EXPECTED_STATE
-
-
Constructor Summary
Constructors Constructor Description NamedBeanExpectedValue(T bean, java.lang.String name, S state)
Create a NamedBeanExpectedValue, using the provided tracked name for the NamedBean.NamedBeanExpectedValue(T bean, S state)
Create a NamedBeanExpectedValue, usingNamedBean.getDisplayName()
to provide the tracked name for the NamedBean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description S
getExpectedState()
Get the expected state.java.lang.String
getName()
Get the name of the contained NamedBean object.T
getObject()
Get the Object this records the expected state for.void
setExpectedState(S state)
Set the expected state.-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
Constructor Detail
-
NamedBeanExpectedValue
public NamedBeanExpectedValue(@Nonnull T bean, @Nonnull java.lang.String name, @Nonnull S state)
Create a NamedBeanExpectedValue, using the provided tracked name for the NamedBean.- Parameters:
bean
- the beanname
- the namestate
- the expected state
-
NamedBeanExpectedValue
public NamedBeanExpectedValue(@Nonnull T bean, S state)
Create a NamedBeanExpectedValue, usingNamedBean.getDisplayName()
to provide the tracked name for the NamedBean.- Parameters:
bean
- the beanstate
- the expected state
-
-
Method Detail
-
getExpectedState
public S getExpectedState()
Description copied from interface:ExpectedState
Get the expected state. This state should not change as the state of the NamedBean changes.- Specified by:
getExpectedState
in interfaceExpectedState<T extends NamedBean,S>
- Returns:
- the expected state
-
setExpectedState
public void setExpectedState(@Nonnull S state) throws java.lang.UnsupportedOperationException
Description copied from interface:ExpectedState
Set the expected state.If UnsupportedOperationException is not thrown, this must fire a
PropertyChangeEvent
with the name "expectedState"- Specified by:
setExpectedState
in interfaceExpectedState<T extends NamedBean,S>
- Parameters:
state
- the new expected state- Throws:
java.lang.UnsupportedOperationException
- if the implementing class does not allow states to be set
-
getObject
@Nonnull public T getObject()
Description copied from interface:ExpectedState
Get the Object this records the expected state for.- Specified by:
getObject
in interfaceExpectedState<T extends NamedBean,S>
- Returns:
- the associated object
-
-