Package VASSAL.property
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
public class SinglePropertyContainer<V> extends Object implements 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
Fields Modifier and Type Field Description protected CopyOnWriteArrayList<PropertyListener<Object>>listenersprotected CopyOnWriteArrayList<PropertyListener<? super V>>plistenersprotected Property<V>propprotected Vvalue -
Constructor Summary
Constructors Constructor Description SinglePropertyContainer(Property<V> prop, V value)Creates a container for a singleProperty. -
Method Summary
Modifier and Type Method Description <T> voidaddPropertyListener(Property<T> prop, PropertyListener<? super T> l)Adds a listener for a specificProperty.voidaddPropertyListener(PropertyListener<Object> l)Adds a listener for all changes to this container.Set<Property<?>>getProperties()Returns thePropertys known to this container.List<PropertyListener<Object>>getPropertyListeners()Returns a list ofPropertyListeners listening to all changes to this container.<T> List<PropertyListener<? super T>>getPropertyListeners(Property<T> prop)Returns a list ofPropertyListeners listening to a givenProperty.<T> TgetValue(Property<T> prop)Gets the value of aProperty.booleanhasListeners()Checks whether there arePropertyListeners for all changes to this container.<T> booleanhasListeners(Property<T> prop)Checks whether there arePropertyListeners for a givenProperty.<T> voidremovePropertyListener(Property<T> prop, PropertyListener<? super T> l)Removes a listener for a specificProperty.voidremovePropertyListener(PropertyListener<Object> l)Removes a listner for all changes to this container.<T> voidsetValue(Property<T> prop, T value)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- ifproporvalueisnull
-
-
Method Details
-
getProperties
Returns thePropertys known to this container.- Specified by:
getPropertiesin interfacePropertyContainer- Returns:
- a set of known
Propertys
-
setValue
Sets the value of aProperty.- Specified by:
setValuein interfacePropertyContainer- Parameters:
prop- thePropertyvalue- the value
-
getValue
Gets the value of aProperty.- Specified by:
getValuein interfacePropertyContainer- Parameters:
prop- theProperty- Returns:
- the value
-
addPropertyListener
Adds a listener for all changes to this container.- Specified by:
addPropertyListenerin interfacePropertyContainer- Parameters:
l- the listener to add
-
addPropertyListener
Adds a listener for a specificProperty.- Specified by:
addPropertyListenerin interfacePropertyContainer- Parameters:
prop- thePropertyto listen onl- the listener to add
-
removePropertyListener
Removes a listner for all changes to this container.- Specified by:
removePropertyListenerin interfacePropertyContainer- Parameters:
l- the listener to remove
-
removePropertyListener
Removes a listener for a specificProperty.- Specified by:
removePropertyListenerin interfacePropertyContainer- Parameters:
prop- thePropertylistened onl- the listener to remove
-
getPropertyListeners
Returns a list ofPropertyListeners listening to all changes to this container.- Specified by:
getPropertyListenersin interfacePropertyContainer- Returns:
- a list of listeners
-
getPropertyListeners
Returns a list ofPropertyListeners listening to a givenProperty.- Specified by:
getPropertyListenersin interfacePropertyContainer- Parameters:
prop- thePropertylistened on- Returns:
- a list of listeners
-
hasListeners
public boolean hasListeners()Checks whether there arePropertyListeners for all changes to this container.- Specified by:
hasListenersin interfacePropertyContainer- Returns:
trueif there are listeners
-
hasListeners
Checks whether there arePropertyListeners for a givenProperty.- Specified by:
hasListenersin interfacePropertyContainer- Returns:
trueif there are listeners for the given property
-