Class ConcurrentHashMapWithOptionals<K,​V>

  • Type Parameters:
    K - the type of the key
    V - 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 of ConcurrentHashMap with Optional 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>
      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • 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
      • Methods inherited from class java.util.AbstractMap

        clone
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ConcurrentHashMapWithOptionals

        public ConcurrentHashMapWithOptionals()
    • 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 empty Optional. The map manipulation is atomically performed by calling ConcurrentHashMap.putIfAbsent(java.lang.Object, java.lang.Object). If optionalKey is empty, do nothing and return nothing.
        Parameters:
        optionalKey - the key
        value - 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 empty Optional. The map manipulation is atomically performed by calling ConcurrentHashMap.putIfAbsent(java.lang.Object, java.lang.Object).
        Parameters:
        key - the key
        value - the value
        Returns:
        the new key, or nothing