Package com.norconex.commons.lang.map
Class ObservableMap<K,V>
- java.lang.Object
-
- com.norconex.commons.lang.map.ObservableMap<K,V>
-
- Type Parameters:
K
- the type of keys maintained by the map we are observingV
- the type of mapped values
- All Implemented Interfaces:
Serializable
,Map<K,V>
- Direct Known Subclasses:
Properties
public class ObservableMap<K,V> extends Object implements Map<K,V>, Serializable
A map implementation that reports changes to addedIMapChangeListener
instance. Changes are triggered when a value change is detected in the following method calls:put(Object, Object)
,putAll(Map)
,remove(Object)
, andclear()
. This class will not detect changes made to key or value objects modified outside this class. This class can be used as a decorator to otherMap
implementations.- Since:
- 1.4
- Author:
- Pascal Essiembre
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ObservableMap()
ObservableMap(Map<K,V> map)
Decorates map argument as anObservableMap
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMapChangeListener(IMapChangeListener<K,V> listener)
Adds a map change listener.void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
V
get(Object key)
boolean
isEmpty()
Set<K>
keySet()
V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
remove(Object key)
void
removeMapChangeListener(IMapChangeListener<K,V> listener)
Removes a map change listener.int
size()
String
toString()
Collection<V>
values()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
addMapChangeListener
public void addMapChangeListener(IMapChangeListener<K,V> listener)
Adds a map change listener.- Parameters:
listener
- change listener
-
removeMapChangeListener
public void removeMapChangeListener(IMapChangeListener<K,V> listener)
Removes a map change listener.- Parameters:
listener
- change listener
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
-