K - key typeV - value typepublic class ImmutableMap<K,V> extends Object implements Map<K,V>, Cloneable, Serializable
Map implementation that doesn't allow any data modifications to be done.
Unlike Collections.unmodifiableMap(Map) this implementation keeps map data copy.
If you need to provide an unmodifiable reference for your map use Collections implementations or write your own.| Constructor and Description |
|---|
ImmutableMap(Map<K,V> map)
Constructs new
ImmutableMap based on the provided map. |
ImmutableMap(Object... data)
Constructs new
ImmutableMap based on the provided data. |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
protected UnsupportedOperationException |
createModificationException()
Returns new
UnsupportedOperationException instance specific for this implementation. |
Set<Map.Entry<K,V>> |
entrySet() |
V |
get(Object key) |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
remove(Object key) |
int |
size() |
Collection<V> |
values() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompute, computeIfAbsent, computeIfPresent, equals, forEach, getOrDefault, hashCode, merge, putIfAbsent, remove, replace, replace, replaceAllpublic ImmutableMap(Object... data)
ImmutableMap based on the provided data.data - mixed keys and valuespublic ImmutableMap(Map<K,V> map)
ImmutableMap based on the provided map.map - data Mappublic boolean containsKey(Object key)
containsKey in interface Map<K,V>public boolean containsValue(Object value)
containsValue in interface Map<K,V>protected UnsupportedOperationException createModificationException()
UnsupportedOperationException instance specific for this implementation.UnsupportedOperationException instance specific for this implementationCopyright © 2020. All rights reserved.