Class CachedMap<K,​V>

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.io.Serializable, java.lang.AutoCloseable, java.util.Map<K,​V>, Wrapper<java.util.Map<K,​V>>

    public class CachedMap<K,​V>
    extends AbstractMap<K,​V>
    implements Wrapper<java.util.Map<K,​V>>, java.io.Flushable, java.io.Closeable
    See Also:
    Serialized Form
    • Nested Class Summary

      • 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>
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Map<K,​V> cache  
      private static long serialVersionUID  
      private java.util.Map<K,​V> source  
    • Constructor Summary

      Constructors 
      Constructor Description
      CachedMap​(java.util.Map<K,​V> source)  
      CachedMap​(java.util.Map<K,​V> source, java.util.Map<K,​V> cache)  
    • Field Detail

      • source

        private transient java.util.Map<K,​V> source
      • cache

        private transient java.util.Map<K,​V> cache
    • Constructor Detail

      • CachedMap

        public CachedMap​(java.util.Map<K,​V> source)
      • CachedMap

        public CachedMap​(java.util.Map<K,​V> source,
                         java.util.Map<K,​V> cache)
    • Method Detail

      • clear

        public void clear()
        Specified by:
        clear in interface java.util.Map<K,​V>
        Specified by:
        clear in class AbstractMap<K,​V>
      • containsKey

        public boolean containsKey​(java.lang.Object key)
        Specified by:
        containsKey in interface java.util.Map<K,​V>
        Overrides:
        containsKey in class AbstractMap<K,​V>
      • containsValue

        public boolean containsValue​(java.lang.Object value)
        Specified by:
        containsValue in interface java.util.Map<K,​V>
        Overrides:
        containsValue in class AbstractMap<K,​V>
      • get

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

        public boolean isEmpty()
        Specified by:
        isEmpty in interface java.util.Map<K,​V>
        Overrides:
        isEmpty in class AbstractMap<K,​V>
      • keySet

        public java.util.Set<K> keySet()
        Specified by:
        keySet in interface java.util.Map<K,​V>
        Specified by:
        keySet in class AbstractMap<K,​V>
      • put

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

        public void putAll​(java.util.Map<? extends K,​? extends V> m)
        Specified by:
        putAll in interface java.util.Map<K,​V>
        Overrides:
        putAll in class AbstractMap<K,​V>
      • remove

        public V remove​(java.lang.Object key)
        Specified by:
        remove in interface java.util.Map<K,​V>
        Specified by:
        remove in class AbstractMap<K,​V>
      • size

        public int size()
        Specified by:
        size in interface java.util.Map<K,​V>
        Specified by:
        size in class AbstractMap<K,​V>
      • getWrappedObject

        public java.util.Map<K,​V> getWrappedObject()
        Description copied from interface: Wrapper
        Returns the object that is wrapped inside the wrapper
        Specified by:
        getWrappedObject in interface Wrapper<K>
        Returns:
        the inner object
      • setWrappedObject

        public void setWrappedObject​(java.util.Map<K,​V> object)
      • getCache

        public java.util.Map<K,​V> getCache()
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Throws:
        java.io.IOException