Class ConcurrentPropertySupport
java.lang.Object
VASSAL.property.ConcurrentPropertySupport
- All Implemented Interfaces:
PropertySupport
A thread-safe implementation of
PropertySupport
.- Since:
- 3.2.0
- Author:
- Joel Uckelman
-
Field Summary
Modifier and TypeFieldDescriptionprotected final CopyOnWriteArrayList
<PropertyListener<Object>> protected final ConcurrentMap
<Property<?>, List<PropertyListener<?>>> -
Constructor Summary
-
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.<T> void
fireChanged
(Object src, Property<T> prop, T oldVal, T newVal) Notifies listeners of a property change.Returns a list ofPropertyListener
s listening to all changes.<T> List
<PropertyListener<? super T>> getPropertyListeners
(Property<T> prop) Returns a list ofPropertyListener
s listening to a givenProperty
.boolean
Checks whether there arePropertyListener
s for all changes.<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.
-
Field Details
-
listeners
-
plisteners
-
-
Constructor Details
-
ConcurrentPropertySupport
public ConcurrentPropertySupport()
-
-
Method Details
-
addPropertyListener
Adds a listener for all changes.- Specified by:
addPropertyListener
in interfacePropertySupport
- Parameters:
l
- the listener to add- Throws:
IllegalArgumentException
- ifl
isnull
-
removePropertyListener
Removes a listener for all changes.- Specified by:
removePropertyListener
in interfacePropertySupport
- Parameters:
l
- the listener to remove- Throws:
IllegalArgumentException
- ifl
isnull
-
hasListeners
public boolean hasListeners()Checks whether there arePropertyListener
s for all changes.- Specified by:
hasListeners
in interfacePropertySupport
- Returns:
true
if there are listeners
-
getPropertyListeners
Returns a list ofPropertyListener
s listening to all changes.- Specified by:
getPropertyListeners
in interfacePropertySupport
- Returns:
- a list of listeners
-
addPropertyListener
Adds a listener for a specificProperty
.- Specified by:
addPropertyListener
in interfacePropertySupport
- Parameters:
prop
- theProperty
to listen onl
- the listener to add
-
removePropertyListener
Removes a listener for a specificProperty
.- Specified by:
removePropertyListener
in interfacePropertySupport
- Parameters:
prop
- theProperty
listened onl
- the listener to remove
-
getPropertyListeners
Returns a list ofPropertyListener
s listening to a givenProperty
.- Specified by:
getPropertyListeners
in interfacePropertySupport
- Parameters:
prop
- theProperty
listened on- Returns:
- a list of listeners
-
hasListeners
Checks whether there arePropertyListener
s for a givenProperty
.- Specified by:
hasListeners
in interfacePropertySupport
- Returns:
true
if there are listeners for the given property
-
fireChanged
Notifies listeners of a property change.- Specified by:
fireChanged
in interfacePropertySupport
- Parameters:
src
- the source of the changeprop
- the changedProperty
oldVal
- the old value of theProperty
newVal
- the new value of theProperty
-