Class LazyHashMap<K,​V>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.util.Map<K,​V>

    public class LazyHashMap<K,​V>
    extends java.util.HashMap<K,​V>
    implements java.util.Map<K,​V>
    A map that can delay the computation of certain values up until the moment that they are actually needed. Useful for expensive to compute values such as the SHA-256. This map does not support null values.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  LazyHashMap.LazyValue<K,​V>  
      • 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>
    • Constructor Summary

      Constructors 
      Constructor Description
      LazyHashMap​(java.util.Collection<LazyHashMap.LazyValue<K,​V>> lazyValues)
      This map behaves like a normal HashMap, expect for the entries passed in as lazy values.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V get​(java.lang.Object key)  
      V put​(K key, V value)  
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, getOrDefault, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
    • Constructor Detail

      • LazyHashMap

        public LazyHashMap​(java.util.Collection<LazyHashMap.LazyValue<K,​V>> lazyValues)
        This map behaves like a normal HashMap, expect for the entries passed in as lazy values. A lazy value is a Callable object associated with a key. When the key is looked up and it's one of the lazy values, the value will be computed at that point and stored in the map. If the value is looked up again, it will be served from the map as usual.
        Parameters:
        lazyValues -
    • Method Detail

      • get

        public V get​(java.lang.Object key)
        Specified by:
        get in interface java.util.Map<K,​V>
        Overrides:
        get in class java.util.HashMap<K,​V>
      • put

        public V put​(K key,
                     V value)
        Specified by:
        put in interface java.util.Map<K,​V>
        Overrides:
        put in class java.util.HashMap<K,​V>