K
- the type of keys maintained by the map we are observingV
- the type of mapped valuespublic class MapChangeSupport<K,V> extends Object implements Serializable
MapChangeSupport
usage:
public class MyMap extends Map { private final MapChangeSupport mcs = new MapChangeSupport(this); public void addMapChangeListener(IMapChangeListener listener) { this.mcs.addMapChangeListener(listener); } public void removeMapChangeListener(IMapChangeListener listener) { this.mcs.removeMapChangeListener(listener); } public Object put(Object key, Object value) { Object oldValue = map.put(key, value); mcs.fireMapChange(key, oldValue, value); return oldValue; } [...] }
Constructor and Description |
---|
MapChangeSupport(Map<K,V> source) |
Modifier and Type | Method and Description |
---|---|
void |
addMapChangeListener(IMapChangeListener<K,V> listener)
Add a
IMapChangeListener to the listener list. |
void |
fireMapChange(K key,
V oldValue,
V newValue)
Fires a
MapChangeEvent to all change listeners. |
boolean |
isEmpty() |
void |
removeMapChangeListener(IMapChangeListener<K,V> listener)
Removes a
IMapChangeListener from the listener list. |
public void addMapChangeListener(IMapChangeListener<K,V> listener)
IMapChangeListener
to the listener list.
If listener
is null, no exception is thrown and no action
is taken.listener
- The IMapChangeListener
to be addedpublic void removeMapChangeListener(IMapChangeListener<K,V> listener)
IMapChangeListener
from the listener list.
If listener
is null, no exception is thrown and no action
is taken.listener
- The IMapChangeListener
to be removedpublic void fireMapChange(K key, V oldValue, V newValue)
MapChangeEvent
to all change listeners.key
- the key for the value changeoldValue
- the old valuenewValue
- the new valuepublic boolean isEmpty()
Copyright © 2008–2021 Norconex Inc.. All rights reserved.