K
- The key typeV
- The value typepublic class LazyInitializedCacheMap<K,V> extends Object implements Map<K,V>
IoBuffer
for example.
Based on the final implementation of Memoizer written by Brian Goetz and Tim
Peierls. This implementation will return an
UnsupportedOperationException
on each method that is not intended to
be called by user code for performance reasons.Modifier and Type | Class and Description |
---|---|
class |
LazyInitializedCacheMap.NoopInitializer
This class provides a noop
LazyInitializer meaning it
will return the same object it received when instantiated. |
Constructor and Description |
---|
LazyInitializedCacheMap()
Default constructor.
|
LazyInitializedCacheMap(ConcurrentHashMap<K,LazyInitializer<V>> map)
This constructor allows to provide a fine tuned
ConcurrentHashMap
to stick with each special case the user needs. |
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value)
Throws
UnsupportedOperationException as this method would imply
performance drops. |
Set<Map.Entry<K,V>> |
entrySet()
Throws
UnsupportedOperationException as this method would imply
performance drops. |
V |
get(Object key) |
Collection<LazyInitializer<V>> |
getValues() |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
putIfAbsent(K key,
LazyInitializer<V> value)
If the specified key is not already associated
with a value, associate it with the given value.
|
V |
remove(Object key) |
int |
size() |
Collection<V> |
values()
Throws
UnsupportedOperationException as this method would imply
performance drops. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAll
public LazyInitializedCacheMap()
ConcurrentHashMap
.public LazyInitializedCacheMap(ConcurrentHashMap<K,LazyInitializer<V>> map)
ConcurrentHashMap
to stick with each special case the user needs.map
- The map to use as a cachepublic V putIfAbsent(K key, LazyInitializer<V> value)
if (!map.containsKey(key)) return map.put(key, value); else return map.get(key);except that the action is performed atomically.
key
- key with which the specified value is to be associatedvalue
- a lazy initialized value object.public boolean containsValue(Object value)
UnsupportedOperationException
as this method would imply
performance drops.containsValue
in interface Map<K,V>
public Collection<V> values()
UnsupportedOperationException
as this method would imply
performance drops.public Set<Map.Entry<K,V>> entrySet()
UnsupportedOperationException
as this method would imply
performance drops.public Collection<LazyInitializer<V>> getValues()
public boolean containsKey(Object key)
containsKey
in interface Map<K,V>
Copyright © 2004–2018 Apache MINA Project. All rights reserved.