K
- V
- public class DefaultValueMap<K,V>
extends com.google.common.collect.ForwardingMap<K,V>
Map
that provides default values. When the get(Object)
method is invoked and the underlying
map does not contain the given key, the default value is stored in the map under the given key. The new value is then
returned from the methods.
This class is not thread-safe and needs to be externally synchronized. It is not thread safe even if the delegate map is.
The semantics of ForwardingMap.keySet()
, ForwardingMap.containsKey(Object)
, ForwardingMap.containsValue(Object)
and ForwardingMap.values()
are
not modified by this wrapper.Modifier and Type | Method and Description |
---|---|
protected Map<K,V> |
delegate() |
V |
get(Object key) |
static <K,V> DefaultValueMap<K,V> |
hashMapWithDefaultValue(com.google.common.base.Supplier<V> defaultValueSupplier) |
static <K,V> DefaultValueMap<K,V> |
of(Map<K,V> delegate,
com.google.common.base.Supplier<V> defaultValueSupplier) |
clear, containsKey, containsValue, entrySet, equals, hashCode, isEmpty, keySet, put, putAll, remove, size, standardClear, standardContainsKey, standardContainsValue, standardEquals, standardHashCode, standardIsEmpty, standardPutAll, standardRemove, standardToString, values
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public static <K,V> DefaultValueMap<K,V> of(Map<K,V> delegate, com.google.common.base.Supplier<V> defaultValueSupplier)
public static <K,V> DefaultValueMap<K,V> hashMapWithDefaultValue(com.google.common.base.Supplier<V> defaultValueSupplier)
Copyright © 2014 Seam Framework. All rights reserved.