| org.mmbase.util.LinkMap
LinkMap | public class LinkMap extends AbstractMap (Code) | | Combines to Maps to one new map. One map is 'leading' and determins wich keys are mapped. The second map can override values, if it contains the same mapping.
There are several ways to describe what must happen with changes on the map.
You can e.g. maintain original values of a map values like so:
Map originals = new HashMap();
Map wrapper = new LinkMap(values, originals, LinkMap.Changes.CONSERVE);
wrapper.put(key, value);
Object newValue = values.get(key);
Object originalValue = originals.get(key);
assert originalValue == wrapper.get(key);
Changes on a map can be made temporay by wrapping it like this:
Map wrapper = new LinkMap(values, new HashMap(), LinkMap.Changes.SECOND);
wrapper.put(key, value);
Object newValue = wrapper.get(key);
Object oldValue = values.get(key);
assert value == newValue;
author: Michiel Meeuwissen version: $Id: LinkMap.java,v 1.3 2007/12/05 20:40:01 michiel Exp $ since: MMBase-1.9 |
Inner Class :public enum Changes | |
Constructor Summary | |
public | LinkMap(Map<K, V> m1, Map<K, V> m2, Changes c) Creates a (modifiable) Linked Map. | public | LinkMap(Map<K, V> m1, Map<K, V> m2) |
LinkMap | public LinkMap(Map<K, V> m1, Map<K, V> m2, Changes c)(Code) | | Creates a (modifiable) Linked Map. What precisely happens on modification is ruled by the c parameter.
See Also: Changes.FIRST See Also: Changes.SECOND See Also: Changes.BOTH See Also: Changes.CONSERVE See Also: Changes.NONE |
LinkMap | public LinkMap(Map<K, V> m1, Map<K, V> m2)(Code) | | Creates an unmodifiable Linked Map
|
put | public V put(K key, V v)(Code) | | |
|
|