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 addedIMapChangeListenerinstance. 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 otherMapimplementations.- 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 voidaddMapChangeListener(IMapChangeListener<K,V> listener)Adds a map change listener.voidclear()booleancontainsKey(Object key)booleancontainsValue(Object value)Set<Map.Entry<K,V>>entrySet()Vget(Object key)booleanisEmpty()Set<K>keySet()Vput(K key, V value)voidputAll(Map<? extends K,? extends V> m)Vremove(Object key)voidremoveMapChangeListener(IMapChangeListener<K,V> listener)Removes a map change listener.intsize()StringtoString()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:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValuein interfaceMap<K,V>
-
-