Package org.opendaylight.yangtools.util
Class UnmodifiableMap<K,V>
- java.lang.Object
-
- org.opendaylight.yangtools.util.UnmodifiableMap<K,V>
-
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values
- All Implemented Interfaces:
Map<K,V>
,Immutable
,MutationBehaviour<Immutable>
@Beta public final class UnmodifiableMap<K,V> extends Object implements Map<K,V>, Immutable
An unmodifiable view over aMap
. Unlike the view returned viaCollections.unmodifiableMap(Map)
, this class checks its argument to ensure multiple encapsulation does not occur.This class checks the argument so it prevents multiple encapsulation. Subclasses of
ImmutableMap
are also recognized and not encapsulated.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
boolean
containsKey(Object key)
boolean
containsValue(Object value)
Set<Map.Entry<K,V>>
entrySet()
boolean
equals(Object obj)
V
get(Object key)
int
hashCode()
boolean
isEmpty()
Set<K>
keySet()
static <K,V>
@NonNull Map<K,V>of(@NonNull Map<K,V> map)
Create an unmodifiable view of the targetMap
.V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
remove(Object key)
int
size()
String
toString()
Collection<V>
values()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
-
-
-
-
Method Detail
-
of
public static <K,V> @NonNull Map<K,V> of(@NonNull Map<K,V> map)
Create an unmodifiable view of the targetMap
. If the map is known to be unmodifiable, that same instance is returned. Otherwise an unmodifiable view of the map will be returned.- Parameters:
map
- Target map- Returns:
- An unmodifiable view of the map
- Throws:
NullPointerException
- ifmap
is null
-
containsKey
public boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
hashCode
public int hashCode()
-
equals
public boolean equals(Object obj)
-
-