mirrormap.collections
Interface IMapListener<K,V>

Type Parameters:
K - The key type for the map this listener is attached to
V - The value type for the map this listener is attached to
All Known Implementing Classes:
MapListenerAdapter

public interface IMapListener<K,V>

Receives notifications of changes to the underlying Map wrapped by a NotifyingMap. The changes to the map are categorised into the following:

For each change, the listener receives a 'before' and 'after' event. So for an add, the listener has the willAdd(Object, Object) method invoked, the entry is added to the underlying map, then the listener has the didAdd(Object, Object) method invoked.

Implementations need to be thread safe.

Author:
Ramon Servadei

Method Summary
 void didAdd(K key, V value)
          Called after a new entry has been added to the underlying Map of a NotifyingMap.
 void didRemove(K key, V value)
          Called after an entry in the underlying Map of a NotifyingMap is removed
 void didUpdate(K key, V oldValue, V newValue)
          Called after an entry in the underlying Map of a NotifyingMap has been updated.
 void willAdd(K key, V value)
          Called before a new entry is added to the underlying Map of a NotifyingMap.
 void willRemove(K key)
          Called before an entry in the underlying Map of a NotifyingMap is removed
 void willUpdate(K key, V currentValue, V newValue)
          Called before an entry in the underlying Map of a NotifyingMap is updated.
 

Method Detail

willAdd

void willAdd(K key,
             V value)
Called before a new entry is added to the underlying Map of a NotifyingMap.

Parameters:
key - the map entry key
value - the value

didAdd

void didAdd(K key,
            V value)
Called after a new entry has been added to the underlying Map of a NotifyingMap.

Parameters:
key - the map entry key
value - the value

willUpdate

void willUpdate(K key,
                V currentValue,
                V newValue)
Called before an entry in the underlying Map of a NotifyingMap is updated.

Parameters:
key - the map entry key
currentValue - the current value associated with the key (this will be replaced with the newValue)
newValue - the new value that will be associated with the key

didUpdate

void didUpdate(K key,
               V oldValue,
               V newValue)
Called after an entry in the underlying Map of a NotifyingMap has been updated.

Parameters:
key - the map entry key
oldValue - the previous value associated with the key
newValue - the current value that is associated with the key (this replaced the oldValue)

willRemove

void willRemove(K key)
Called before an entry in the underlying Map of a NotifyingMap is removed

Parameters:
key - the map entry key that will be removed

didRemove

void didRemove(K key,
               V value)
Called after an entry in the underlying Map of a NotifyingMap is removed

Parameters:
key - the map entry key that was removed
value - the value of the associated key that was removed


Copyright © 2010. All Rights Reserved.