Class SinglePropertyContainer<V>
java.lang.Object
VASSAL.property.SinglePropertyContainer<V>
- Type Parameters:
V
- the class of the value of the containedProperty
- All Implemented Interfaces:
PropertyContainer
A
PropertyContainer
which holds one Property
.
This class is intended for testing purposes only. It will not
generally be useful to have a dedicated container which holds only
one Property
.- Since:
- 3.2.0
- Author:
- Joel Uckelman
-
Field Summary
Modifier and TypeFieldDescriptionprotected final CopyOnWriteArrayList
<PropertyListener<Object>> protected final CopyOnWriteArrayList
<PropertyListener<? super V>> protected V
-
Constructor Summary
ConstructorDescriptionSinglePropertyContainer
(Property<V> prop, V value) Creates a container for a singleProperty
. -
Method Summary
Modifier and TypeMethodDescription<T> void
addPropertyListener
(Property<T> prop, PropertyListener<? super T> l) Adds a listener for a specificProperty
.void
Adds a listener for all changes to this container.Returns theProperty
s known to this container.Returns a list ofPropertyListener
s listening to all changes to this container.<T> List
<PropertyListener<? super T>> getPropertyListeners
(Property<T> prop) Returns a list ofPropertyListener
s listening to a givenProperty
.<T> T
Gets the value of aProperty
.boolean
Checks whether there arePropertyListener
s for all changes to this container.<T> boolean
hasListeners
(Property<T> prop) Checks whether there arePropertyListener
s for a givenProperty
.<T> void
removePropertyListener
(Property<T> prop, PropertyListener<? super T> l) Removes a listener for a specificProperty
.void
Removes a listener for all changes to this container.<T> void
Sets the value of aProperty
.
-
Field Details
-
prop
-
value
-
listeners
-
plisteners
-
-
Constructor Details
-
SinglePropertyContainer
Creates a container for a singleProperty
.- Parameters:
prop
- the propertyvalue
- the initial value of the property- Throws:
IllegalArgumentException
- ifprop
orvalue
isnull
-
-
Method Details
-
getProperties
Returns theProperty
s known to this container.- Specified by:
getProperties
in interfacePropertyContainer
- Returns:
- a set of known
Property
s
-
setValue
Sets the value of aProperty
.- Specified by:
setValue
in interfacePropertyContainer
- Parameters:
prop
- theProperty
value
- the value
-
getValue
Gets the value of aProperty
.- Specified by:
getValue
in interfacePropertyContainer
- Parameters:
prop
- theProperty
- Returns:
- the value
-
addPropertyListener
Adds a listener for all changes to this container.- Specified by:
addPropertyListener
in interfacePropertyContainer
- Parameters:
l
- the listener to add
-
addPropertyListener
Adds a listener for a specificProperty
.- Specified by:
addPropertyListener
in interfacePropertyContainer
- Parameters:
prop
- theProperty
to listen onl
- the listener to add
-
removePropertyListener
Removes a listener for all changes to this container.- Specified by:
removePropertyListener
in interfacePropertyContainer
- Parameters:
l
- the listener to remove
-
removePropertyListener
Removes a listener for a specificProperty
.- Specified by:
removePropertyListener
in interfacePropertyContainer
- Parameters:
prop
- theProperty
listened onl
- the listener to remove
-
getPropertyListeners
Returns a list ofPropertyListener
s listening to all changes to this container.- Specified by:
getPropertyListeners
in interfacePropertyContainer
- Returns:
- a list of listeners
-
getPropertyListeners
Returns a list ofPropertyListener
s listening to a givenProperty
.- Specified by:
getPropertyListeners
in interfacePropertyContainer
- Parameters:
prop
- theProperty
listened on- Returns:
- a list of listeners
-
hasListeners
public boolean hasListeners()Checks whether there arePropertyListener
s for all changes to this container.- Specified by:
hasListeners
in interfacePropertyContainer
- Returns:
true
if there are listeners
-
hasListeners
Checks whether there arePropertyListener
s for a givenProperty
.- Specified by:
hasListeners
in interfacePropertyContainer
- Returns:
true
if there are listeners for the given property
-