Package com.globalmentor.collections
Class SynchronizedMapDecorator<K,V>
java.lang.Object
com.globalmentor.collections.SynchronizedMapDecorator<K,V>
- Type Parameters:
K
- The type of key used in the map.V
- The type of value stored in the map.
- All Implemented Interfaces:
Map<K,
V>
- Direct Known Subclasses:
SynchronizedCollectionMapDecorator
A map that wraps an existing map, providing access through the
Map
interface. All map access is synchronized on the provided synchronization object.- Author:
- Garret Wilson
-
Nested Class Summary
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSynchronizedMapDecorator
(Map<K, V> map) Map constructor.SynchronizedMapDecorator
(Map<K, V> map, Object mutex) Map and mutex constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
computeIfAbsent
(K key, Function<? super K, ? extends V> mappingFunction) computeIfPresent
(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) boolean
containsKey
(Object key) boolean
containsValue
(Object value) entrySet()
boolean
void
forEach
(BiConsumer<? super K, ? super V> action) getOrDefault
(Object key, V defaultValue) int
hashCode()
boolean
isEmpty()
keySet()
void
putIfAbsent
(K key, V value) boolean
boolean
void
replaceAll
(BiFunction<? super K, ? super V, ? extends V> function) int
size()
values()
-
Field Details
-
map
The map this class decorates. -
mutex
The mutual exclusion synchronization object.
-
-
Constructor Details
-
SynchronizedMapDecorator
Map constructor. The new instance of this class is used as a mutex.- Parameters:
map
- The map this map should decorate.- Throws:
NullPointerException
- if the provided map isnull
.
-
SynchronizedMapDecorator
Map and mutex constructor.- Parameters:
map
- The map this map should decorate.mutex
- The mutual exclusion synchronization object.- Throws:
NullPointerException
- if the provided map and/or mutex isnull
.
-
-
Method Details
-
size
public int size() -
isEmpty
public boolean isEmpty() -
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
get
-
put
-
remove
-
putAll
-
clear
public void clear() -
keySet
-
values
-
entrySet
-
equals
-
hashCode
public int hashCode() -
getOrDefault
- Specified by:
getOrDefault
in interfaceMap<K,
V>
-
forEach
-
replaceAll
- Specified by:
replaceAll
in interfaceMap<K,
V>
-
putIfAbsent
- Specified by:
putIfAbsent
in interfaceMap<K,
V>
-
remove
-
replace
-
replace
-
computeIfAbsent
- Specified by:
computeIfAbsent
in interfaceMap<K,
V>
-
computeIfPresent
- Specified by:
computeIfPresent
in interfaceMap<K,
V>
-
compute
-
merge
-