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:
java.io.Serializable
,java.util.concurrent.ConcurrentMap<K,V>
,java.util.Map<K,V>
public class ConcurrentHashMapWithOptionals<K,V> extends java.util.concurrent.ConcurrentHashMap<K,V>
A specialisation ofConcurrentHashMap
withOptional
support.- 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
java.util.concurrent.ConcurrentHashMap.KeySetView<K extends java.lang.Object,V extends java.lang.Object>
-
-
Constructor Summary
Constructors Constructor Description ConcurrentHashMapWithOptionals()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Optional<K>
putIfAbsentAndGetNewKey(java.util.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.java.util.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
-
-
-
-
Method Detail
-
putIfAbsentAndGetNewKey
@Nonnull public java.util.Optional<K> putIfAbsentAndGetNewKey(@Nonnull java.util.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)
. IfoptionalKey
is empty, do nothing and return nothing.- Parameters:
optionalKey
- the keyvalue
- the value- Returns:
- the new key, or nothing
-
putIfAbsentAndGetNewKey
@Nonnull public java.util.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
-
-