Class JKGuavaCacheWrapper<K,V>

java.lang.Object
com.jk.core.collections.map.JKGuavaCacheWrapper<K,V>
Type Parameters:
K - Specifies the type of the key associated with the cache value.
V - Specifies the cache value type that is associated with the key.
All Implemented Interfaces:
JKMap<K,V>

public class JKGuavaCacheWrapper<K,V> extends Object implements JKMap<K,V>
This class represents a wrapper class that stores cache entries and provides the necessary method to interact with and access the cache stored within.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
    JKGuavaCacheWrapper(com.google.common.cache.Cache<K,V> cache)
    This method constructs a new instance of the JKGuavaCacheWrapper with the provided parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    This method returns the current JKMap entries as a Map.
    void
    This method clears all the map entries.
    boolean
    This method checks whether this map contains the specified key or not.
    get(K k)
    This method gets the value to which the specified key is mapped in this map.
    This method returns the keys set of this map.
    void
    put(K k, V v)
    This method associates the specified value with the specified key in this map.
    remove(K key)
    This method removes the entry that is associated with the specified key, and return the value of the removed entry.
    Returns a string representation of the object.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • JKGuavaCacheWrapper

      public JKGuavaCacheWrapper(com.google.common.cache.Cache<K,V> cache)
      This method constructs a new instance of the JKGuavaCacheWrapper with the provided parameters.

      This constructor initializes the object with the specified values for its attributes.

      Parameters:
      cache - Specifies the stored cache entries.
  • Method Details

    • put

      public void put(K k, V v)
      This method associates the specified value with the specified key in this map.
      Specified by:
      put in interface JKMap<K,V>
      Parameters:
      k - Specifies the key with which the specified value is to be associated.
      v - Specifies the value to be associated with the specified key.
    • get

      public V get(K k)
      This method gets the value to which the specified key is mapped in this map.
      Specified by:
      get in interface JKMap<K,V>
      Parameters:
      k - Specifies the key with which the value is associated with.
      Returns:
      the value that is associated with the specified key.
    • clear

      public void clear()
      This method clears all the map entries.
      Specified by:
      clear in interface JKMap<K,V>
    • keySet

      public Set<K> keySet()
      This method returns the keys set of this map.
      Specified by:
      keySet in interface JKMap<K,V>
      Returns:
      a set of the keys in this map.
    • containsKey

      public boolean containsKey(K key)
      This method checks whether this map contains the specified key or not.
      Specified by:
      containsKey in interface JKMap<K,V>
      Parameters:
      key - Specifies the key to be searched for in this map.
      Returns:
      true, if this map contains the specified key, false, otherwise.
    • remove

      public V remove(K key)
      This method removes the entry that is associated with the specified key, and return the value of the removed entry.

      The map will not contain a mapping for the specified key once the call returns.

      Specified by:
      remove in interface JKMap<K,V>
      Parameters:
      key - Specifies the key which the entry is associated with.
      Returns:
      the associated value in the entry that was removed.
    • toString

      public String toString()
      Returns a string representation of the object.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the object.
    • asMap

      public Map<K,V> asMap()
      This method returns the current JKMap entries as a Map.
      Specified by:
      asMap in interface JKMap<K,V>
      Returns:
      a Map containing all the entries inside the JKMap