org.javimmutable.collections.util
Class MutableMapAdaptor<K,V>
java.lang.Object
java.util.AbstractMap<K,V>
org.javimmutable.collections.util.MutableMapAdaptor<K,V>
- All Implemented Interfaces:
- Map<K,V>
public abstract class MutableMapAdaptor<K,V>
- extends AbstractMap<K,V>
When converting legacy code to use JImmutableMap there are sometimes objects that shared the mutable
version of their internal Map field with other classes. This class serves as a an adaptor to allow
this sharing to continue for a time after converting to JImmutableMap. However the legacy code should
still be changed over time to eliminate the sharing of a mutable Map.
Since a JImmutableMap has to be replaced to reflect any changes to the map it can be difficult to
adapt one of them into a mutable Map. Concrete classes derived from this class only have to implement
two methods, accessMap() and replaceMap() in order to implement the adaptor.
NOTE: this adaptor is NOT thread safe. Do not use it in a multi-threaded environment.
Nested classes/interfaces inherited from interface java.util.Map |
Map.Entry<K,V> |
Methods inherited from class java.util.AbstractMap |
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, toString, values |
MutableMapAdaptor
protected MutableMapAdaptor()
accessMap
protected abstract JImmutableMap<K,V> accessMap()
- Implemented by derived classes to allow this adaptor to access their JImmutableMap instance.
- Returns:
replaceMap
protected abstract void replaceMap(JImmutableMap<K,V> newMap)
- Implemented by derived classes to allow this adaptor to replace their JImmutableMap instance.
entrySet
public Set<Map.Entry<K,V>> entrySet()
- Specified by:
entrySet
in interface Map<K,V>
- Specified by:
entrySet
in class AbstractMap<K,V>
put
public V put(K key,
V value)
- Specified by:
put
in interface Map<K,V>
- Overrides:
put
in class AbstractMap<K,V>
Copyright © 2014 Burton Computer Corporation. All rights reserved.