K
- the key typeV
- the value typepublic class CmsNullIgnoringConcurrentMap<K,V> extends java.lang.Object implements java.util.Map<K,V>
The point of this is the following: Often, HashMaps in older code are accessed concurrently by multiple threads. When these threads modify the map concurrently, an infinite loop may occur due to the standard HashMap implementation. But sometimes we can't just replace the HashMap with a ConcurrentHashMap because that class doesn't allow null values and we don't always know for certain whether null values are used or not. But if we don't care about the distinction about null values and entries not being present, we can use this map class which will just log an error and remove the entry when trying to set a null value. NOTE: Currently this wrapper does *not* check value modifications made to entries returned by entrySet!
Constructor and Description |
---|
CmsNullIgnoringConcurrentMap()
Creates a new instance.
|
CmsNullIgnoringConcurrentMap(java.util.Map<K,V> otherMap)
Creates a new instance from another map.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
boolean |
equals(java.lang.Object o) |
V |
get(java.lang.Object key) |
int |
hashCode() |
boolean |
isEmpty() |
java.util.Set<K> |
keySet() |
V |
put(K key,
V value)
Sets the given map value for the given key, unless either of them is null.
|
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
remove(java.lang.Object key) |
int |
size() |
java.util.Collection<V> |
values() |
public CmsNullIgnoringConcurrentMap()
public CmsNullIgnoringConcurrentMap(java.util.Map<K,V> otherMap)
otherMap
- the other mappublic boolean containsKey(java.lang.Object key)
public boolean containsValue(java.lang.Object value)
public boolean equals(java.lang.Object o)
public int hashCode()
public boolean isEmpty()
public V put(K key, V value)
If the value is null,