common
Interface MapDiff

All Superinterfaces:
java.util.Map
All Known Implementing Classes:
HashMapDiff, MapWithPreimagesDiff

public interface MapDiff
extends java.util.Map

A map that is represented as a set of changes to some underlying map. A MapDiff object can be modified, but changes to the MapDiff do not affect the underlying map unless changeUnderlyingMap is called. The advantages of using a MapDiff rather than creating another Map object are:

A MapDiff behaves correctly if entries are placed in the underlying map after the MapDiff is created. It also behaves correctly if entries are removed from the underlying map, as long as those keys have not also been removed from the MapDiff (then they may be double-counted).


Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Method Summary
 void changeUnderlying()
          Changes the underlying map so it is equal to this map.
 void clearChanges()
          Resets this map so it is equal to the underlying map.
 java.util.Set getChangedKeys()
          Returns the set of keys that map to different values in this map than in the underlying map.
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, values
 

Method Detail

getChangedKeys

java.util.Set getChangedKeys()
Returns the set of keys that map to different values in this map than in the underlying map. This includes any keys that have values in this map but not the underlying map, or vice versa.

The returned set may or may not be kept up to date as changes are made to this MapDiff.

Returns:
unmodifiable Set of Object

changeUnderlying

void changeUnderlying()
Changes the underlying map so it is equal to this map.

Throws:
java.lang.UnsupportedOperationException - if the underlying map is not modifiable

clearChanges

void clearChanges()
Resets this map so it is equal to the underlying map.