org.omnaest.utils.cache
Class MapToCacheAdapter<K,V>

java.lang.Object
  extended by org.omnaest.utils.cache.MapToCacheAdapter<K,V>
Type Parameters:
K -
V -
All Implemented Interfaces:
Serializable, Map<K,V>, Cache<K,V>

public final class MapToCacheAdapter<K,V>
extends Object

Adapter from Map to Cache

Note: entrySet(), values() and keySet() will return an unmodifiable instance

Author:
Omnaest
See Also:
Cache, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
MapToCacheAdapter(Map<? extends K,? extends V> map)
           
 
Method Summary
 void clear()
           
 boolean containsKey(Object key)
           
 boolean containsValue(Object value)
           
 Set<Map.Entry<K,V>> entrySet()
          Returns an unmodifiable Set of all Map.Entrys within the Cache which only represents a snapshot in moment
 boolean equals(Object o)
           
 V get(Object key)
           
 V getOrCreate(K key, Factory<V> factory)
          Gets a cached value or creates a new one using the given Factory and puts the new value into the cache.
 int hashCode()
           
 boolean isEmpty()
           
 Set<K> keySet()
          Returns an unmodifiable Set of all keys within the Cache which only represents a snapshot in moment
 V put(K key, V value)
           
 void putAll(Map<? extends K,? extends V> m)
           
 V remove(Object key)
           
 int size()
           
 Collection<V> values()
          Returns an unmodifiable Collection of all values within the Cache which only represents a snapshot in moment
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapToCacheAdapter

public MapToCacheAdapter(Map<? extends K,? extends V> map)
Parameters:
map -
See Also:
MapToCacheAdapter
Method Detail

size

public int size()

isEmpty

public boolean isEmpty()

containsKey

public boolean containsKey(Object key)

containsValue

public boolean containsValue(Object value)

get

public V get(Object key)

put

public V put(K key,
             V value)

remove

public V remove(Object key)

putAll

public void putAll(Map<? extends K,? extends V> m)

clear

public void clear()

keySet

public Set<K> keySet()
Description copied from interface: Cache
Returns an unmodifiable Set of all keys within the Cache which only represents a snapshot in moment


values

public Collection<V> values()
Description copied from interface: Cache
Returns an unmodifiable Collection of all values within the Cache which only represents a snapshot in moment


entrySet

public Set<Map.Entry<K,V>> entrySet()
Description copied from interface: Cache
Returns an unmodifiable Set of all Map.Entrys within the Cache which only represents a snapshot in moment


equals

public boolean equals(Object o)
Specified by:
equals in interface Map<K,V>
Overrides:
equals in class Object

hashCode

public int hashCode()
Specified by:
hashCode in interface Map<K,V>
Overrides:
hashCode in class Object

getOrCreate

public V getOrCreate(K key,
                     Factory<V> factory)
Description copied from interface: Cache
Gets a cached value or creates a new one using the given Factory and puts the new value into the cache.

Specified by:
getOrCreate in interface Cache<K,V>
Returns:


Copyright © 2013. All Rights Reserved.