K
- key typeV
- value typepublic class DeltaMap<K,V> extends AbstractMap<K,V>
HashMap<String, String> hm = new HashMap<String, String>(); hm.put("a", "apple"); DeltaMapdm = DeltaMap.create(hm); dm.remove("a"); assert hm.containsKey("a"); assert !dm.containsKey("a"); dm.commit(); assert !hm.containsKey("a");
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Method and Description |
---|---|
void |
clear() |
void |
commit()
Commits the changes to the original map.
|
boolean |
containsKey(Object key) |
static <K,V> DeltaMap<K,V> |
create()
Creates and returns a DeltaMap for an empty map.
|
static <K,V> DeltaMap<K,V> |
create(Map<K,V> original)
Creates and returns a DeltaMap for an original map.
|
Set<Map.Entry<K,V>> |
entrySet() |
static <K,V> DeltaMap<K,V> |
excludeKeys(Map<K,V> original,
K... exclude)
Creates and returns a DeltaMap for an original map, excluding some key mappings.
|
static <K,V> DeltaMap<K,V> |
excludeKeys(Map<K,V> original,
Set<K> exclude)
Creates and returns a DeltaMap for an original map, excluding some key mappings.
|
V |
get(Object key) |
Map<K,V> |
getChanged()
Returns a Map of the entries changed, not including those removed.
|
Map<K,V> |
getOriginal()
Returns the original wrapped Map.
|
Set<K> |
getRemoved()
Returns the entries removed, including entries excluded by the constructor.
|
boolean |
isModified()
Returns true if the internal map was modified.
|
V |
put(K key,
V value) |
V |
remove(Object key) |
void |
setOriginal(Map<K,V> original)
Sets the original values of this delta map.
|
int |
size() |
String |
toDebugString()
Returns a debug string.
|
clone, containsValue, equals, hashCode, isEmpty, keySet, putAll, toString, values
public static <K,V> DeltaMap<K,V> create(Map<K,V> original)
original
- will not be modified, except by commit()
public static <K,V> DeltaMap<K,V> create()
public static <K,V> DeltaMap<K,V> excludeKeys(Map<K,V> original, Set<K> exclude)
original
- will not be modified, except by commit()
exclude
- entries not to includepublic static <K,V> DeltaMap<K,V> excludeKeys(Map<K,V> original, K... exclude)
public int size()
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
containsKey
in class AbstractMap<K,V>
public void commit()
public boolean isModified()
public String toDebugString()
public void clear()
public Map<K,V> getChanged()
Copyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.