Class AtomicMapLookup


  • public class AtomicMapLookup
    extends Object
    A helper that locates or safely constructs and registers atomic maps with a given cache. This should be the only way AtomicMaps are created/retrieved, to prevent concurrent creation, registration and possibly overwriting of such a map within the cache.
    Since:
    4.0
    Author:
    Manik Surtani
    See Also:
    AtomicMap
    • Constructor Detail

      • AtomicMapLookup

        public AtomicMapLookup()
    • Method Detail

      • getAtomicMap

        public static <MK,​K,​V> AtomicMap<K,​V> getAtomicMap​(Cache<MK,​?> cache,
                                                                             MK key)
        Retrieves an atomic map from a given cache, stored under a given key. If an atomic map did not exist, one is created and registered in an atomic fashion.
        Type Parameters:
        MK - key param of the cache
        K - key param of the AtomicMap
        V - value param of the AtomicMap
        Parameters:
        cache - underlying cache
        key - key under which the atomic map exists
        Returns:
        an AtomicMap
      • getFineGrainedAtomicMap

        public static <MK,​K,​V> FineGrainedAtomicMap<K,​V> getFineGrainedAtomicMap​(Cache<MK,​?> cache,
                                                                                                   MK key)
        Retrieves a fine grained atomic map from a given cache, stored under a given key. If a fine grained atomic map did not exist, one is created and registered in an atomic fashion.
        Type Parameters:
        MK - key param of the cache
        K - key param of the AtomicMap
        V - value param of the AtomicMap
        Parameters:
        cache - underlying cache
        key - key under which the atomic map exists
        Returns:
        an AtomicMap
      • getAtomicMap

        public static <MK,​K,​V> AtomicMap<K,​V> getAtomicMap​(Cache<MK,​?> cache,
                                                                             MK key,
                                                                             boolean createIfAbsent)
        Retrieves an atomic map from a given cache, stored under a given key.
        Type Parameters:
        MK - key param of the cache
        K - key param of the AtomicMap
        V - value param of the AtomicMap
        Parameters:
        cache - underlying cache
        key - key under which the atomic map exists
        createIfAbsent - if true, a new atomic map is created if one doesn't exist; otherwise null is returned if the map didn't exist.
        Returns:
        an AtomicMap, or null if one did not exist.
      • getFineGrainedAtomicMap

        public static <MK,​K,​V> FineGrainedAtomicMap<K,​V> getFineGrainedAtomicMap​(Cache<MK,​?> cache,
                                                                                                   MK key,
                                                                                                   boolean createIfAbsent)
        Retrieves an atomic map from a given cache, stored under a given key.
        Type Parameters:
        MK - key param of the cache
        K - key param of the AtomicMap
        V - value param of the AtomicMap
        Parameters:
        cache - underlying cache
        key - key under which the atomic map exists
        createIfAbsent - if true, a new atomic map is created if one doesn't exist; otherwise null is returned if the map didn't exist.
        Returns:
        an AtomicMap, or null if one did not exist.
      • getReadOnlyAtomicMap

        public static <MK,​K,​V> Map<K,​V> getReadOnlyAtomicMap​(Cache<MK,​?> cache,
                                                                               MK key)
        Retrieves an atomic map from a given cache, stored under a given key, for reading only. The atomic map returned will not support updates, and if the map did not in fact exist, an empty map is returned.
        Type Parameters:
        MK - key param of the cache
        K - key param of the AtomicMap
        V - value param of the AtomicMap
        Parameters:
        cache - underlying cache
        key - key under which the atomic map exists
        Returns:
        an immutable, read-only map
      • removeAtomicMap

        public static <MK> void removeAtomicMap​(Cache<MK,​?> cache,
                                                MK key)
        Removes the atomic map associated with the given key from the underlying cache.
        Type Parameters:
        MK - key param of the cache
        Parameters:
        cache - underlying cache
        key - key under which the atomic map exists