Class DefaultCache<K,​V>

  • Type Parameters:
    K - type for the key
    V - type for the value
    All Implemented Interfaces:
    Cache<K,​V>

    public class DefaultCache<K,​V>
    extends java.lang.Object
    implements Cache<K,​V>
    • Constructor Summary

      Constructors 
      Constructor Description
      DefaultCache()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      V get​(K key)
      Get the value for the specified key, or null when there is no such key.
      void put​(K key, V value)
      Stores a key-value pair in the cache.
      boolean remove​(K key)
      Remove the entry associated with this key.
      void removeAll()
      Remove all entries from the cache
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultCache

        public DefaultCache()
    • Method Detail

      • get

        public V get​(K key)
        Description copied from interface: Cache
        Get the value for the specified key, or null when there is no such key. The latter can be because there never was an entry with this key stored, or the entry with this key has been reclaimed.
        Specified by:
        get in interface Cache<K,​V>
        Parameters:
        key - the key for which we need the value
        Returns:
        the value for the specified key, null in case there is no value corresponding to this key.
      • put

        public void put​(K key,
                        V value)
        Description copied from interface: Cache
        Stores a key-value pair in the cache. A NullPointerException will be thrown if the key or the value are null.
        Specified by:
        put in interface Cache<K,​V>
        Parameters:
        key - the key, should not be null
        value - the value, should not be null
      • remove

        public boolean remove​(K key)
        Description copied from interface: Cache
        Remove the entry associated with this key.
        Specified by:
        remove in interface Cache<K,​V>
        Parameters:
        key - the key for which the entry is requested
        Returns:
        true if the cache contained an entry with this key
      • removeAll

        public void removeAll()
        Description copied from interface: Cache
        Remove all entries from the cache
        Specified by:
        removeAll in interface Cache<K,​V>