Package it.tidalwave.util
Class ConcurrentHashMapWithOptionals<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.concurrent.ConcurrentHashMap<K,V>
-
- it.tidalwave.util.ConcurrentHashMapWithOptionals<K,V>
-
- Type Parameters:
K- the type of the keyV- the type of the value
- All Implemented Interfaces:
Serializable,ConcurrentMap<K,V>,Map<K,V>
public class ConcurrentHashMapWithOptionals<K,V> extends ConcurrentHashMap<K,V>
A specialisation ofConcurrentHashMapwithOptionalsupport.- Since:
- 3.1-ALPHA-2
- Author:
- Fabrizio Giudici
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.concurrent.ConcurrentHashMap
ConcurrentHashMap.KeySetView<K extends Object,V extends Object>
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Constructor Description ConcurrentHashMapWithOptionals()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<K>putIfAbsentAndGetNewKey(Optional<K> optionalKey, V value)If the map doesn't contain the given key, put the new pair(key, value), and return the key itself.Optional<K>putIfAbsentAndGetNewKey(K key, V value)If the map doesn't contain the given key, put the new pair(key, value), and return the key itself.-
Methods inherited from class java.util.concurrent.ConcurrentHashMap
clear, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, forEach, forEach, forEachEntry, forEachEntry, forEachKey, forEachKey, forEachValue, forEachValue, get, getOrDefault, hashCode, isEmpty, keys, keySet, keySet, mappingCount, merge, newKeySet, newKeySet, put, putAll, putIfAbsent, reduce, reduceEntries, reduceEntries, reduceEntriesToDouble, reduceEntriesToInt, reduceEntriesToLong, reduceKeys, reduceKeys, reduceKeysToDouble, reduceKeysToInt, reduceKeysToLong, reduceToDouble, reduceToInt, reduceToLong, reduceValues, reduceValues, reduceValuesToDouble, reduceValuesToInt, reduceValuesToLong, remove, remove, replace, replace, replaceAll, search, searchEntries, searchKeys, searchValues, size, toString, values
-
Methods inherited from class java.util.AbstractMap
clone
-
-
-
-
Method Detail
-
putIfAbsentAndGetNewKey
@Nonnull public Optional<K> putIfAbsentAndGetNewKey(@Nonnull Optional<K> optionalKey, @Nonnull V value)
If the map doesn't contain the given key, put the new pair(key, value), and return the key itself. Otherwise, do nothing and return an emptyOptional. The map manipulation is atomically performed by callingConcurrentHashMap.putIfAbsent(java.lang.Object, java.lang.Object). IfoptionalKeyis empty, do nothing and return nothing.- Parameters:
optionalKey- the keyvalue- the value- Returns:
- the new key, or nothing
-
putIfAbsentAndGetNewKey
@Nonnull public Optional<K> putIfAbsentAndGetNewKey(@Nonnull K key, @Nonnull V value)
If the map doesn't contain the given key, put the new pair(key, value), and return the key itself. Otherwise, do nothing and return an emptyOptional. The map manipulation is atomically performed by callingConcurrentHashMap.putIfAbsent(java.lang.Object, java.lang.Object).- Parameters:
key- the keyvalue- the value- Returns:
- the new key, or nothing
-
-