public class UnmodifiableIdentityHashMap<K,V> extends IdentityHashMap<K,V>
IdentityHashMap
that makes it unmodifiable. All mutating operations
throw UnsupportedOperationException
, and all other operations delegate to the underlying
map.
This class extends IdentityHashMap
only so it is assignable to variables / fields of
static type IdentityHashMap
. All valid operations are delegated to the wrapped map, and
any inherited state from the superclass is unused.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Modifier and Type | Method and Description |
---|---|
void |
clear() |
V |
compute(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
V |
computeIfAbsent(K key,
Function<? super K,? extends V> mappingFunction) |
V |
computeIfPresent(K key,
BiFunction<? super K,? super V,? extends V> remappingFunction) |
boolean |
containsKey(@Nullable Object key) |
boolean |
containsValue(@Nullable Object value) |
Set<Map.Entry<K,V>> |
entrySet() |
boolean |
equals(@Nullable Object o) |
void |
forEach(BiConsumer<? super K,? super V> action) |
V |
get(@Nullable Object key) |
V |
getOrDefault(Object key,
V defaultValue) |
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet() |
V |
merge(K key,
V value,
BiFunction<? super V,? super V,? extends V> remappingFunction) |
V |
put(K key,
V value) |
void |
putAll(Map<? extends K,? extends V> m) |
V |
putIfAbsent(K key,
V value) |
V |
remove(@Nullable Object key) |
boolean |
remove(Object key,
Object value) |
V |
replace(K key,
V value) |
boolean |
replace(K key,
V oldValue,
V newValue) |
void |
replaceAll(BiFunction<? super K,? super V,? extends V> function) |
int |
size() |
String |
toString() |
Collection<V> |
values() |
static <K,V> UnmodifiableIdentityHashMap<K,V> |
wrap(IdentityHashMap<K,V> map)
Create an
UnmodifiableIdentityHashMap wrapper for a map. |
clone
public static <K,V> UnmodifiableIdentityHashMap<K,V> wrap(IdentityHashMap<K,V> map)
UnmodifiableIdentityHashMap
wrapper for a map. Returns the argument if it is
already an UnmodifiableIdentityHashMap
.K
- the key typeV
- the value typemap
- the map to wrappublic int size()
public boolean isEmpty()
public boolean containsKey(@Nullable Object key)
containsKey
in interface Map<K,V>
containsKey
in class IdentityHashMap<K,V>
public boolean containsValue(@Nullable Object value)
containsValue
in interface Map<K,V>
containsValue
in class IdentityHashMap<K,V>
public void clear()
public int hashCode()
public Collection<V> values()
public void forEach(BiConsumer<? super K,? super V> action)
public void replaceAll(BiFunction<? super K,? super V,? extends V> function)
replaceAll
in interface Map<K,V>
replaceAll
in class IdentityHashMap<K,V>
public String toString()
toString
in class AbstractMap<K,V>
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)