Package org.opendaylight.yangtools.util
Class SharedSingletonMap<K,V>
- java.lang.Object
-
- org.opendaylight.yangtools.util.SharedSingletonMap<K,V>
-
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values
- All Implemented Interfaces:
Serializable
,Map<K,V>
,Immutable
,MutationBehaviour<Immutable>
,UnmodifiableMapPhase<K,V>
@Beta public abstract class SharedSingletonMap<K,V> extends Object implements Serializable, UnmodifiableMapPhase<K,V>
Implementation of theMap
interface which stores a single mapping. The key set is shared among all instances which contain the same key. This implementation does not support null keys or values.In case the set of keys is statically known, you can use
SharedSingletonMapTemplate
to efficiently createSharedSingletonMap
instances.- See Also:
- Serialized Form
-
-
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)
@NonNull SingletonSet<Map.Entry<K,V>>
entrySet()
boolean
equals(Object obj)
V
get(Object key)
Map.Entry<K,V>
getEntry()
int
hashCode()
boolean
isEmpty()
@NonNull SingletonSet<K>
keySet()
static <K,V>
@NonNull SharedSingletonMap<K,V>orderedCopyOf(Map<K,V> map)
Create aSharedSingletonMap
of specifiedkey
andvalue
, which retains insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.static <K,V>
@NonNull SharedSingletonMap<K,V>orderedOf(K key, V value)
Create aSharedSingletonMap
of specifiedkey
andvalue
, which retains insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.V
put(K key, V value)
void
putAll(Map<? extends K,? extends V> m)
V
remove(Object key)
int
size()
String
toString()
static <K,V>
@NonNull SharedSingletonMap<K,V>unorderedCopyOf(Map<K,V> map)
Create aSharedSingletonMap
from specified single-element map, which does not retain insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.static <K,V>
@NonNull SharedSingletonMap<K,V>unorderedOf(K key, V value)
Create aSharedSingletonMap
of specifiedkey
andvalue
, which does not retain insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.@NonNull SingletonSet<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
-
Methods inherited from interface org.opendaylight.yangtools.util.UnmodifiableMapPhase
toModifiableMap
-
-
-
-
Method Detail
-
orderedOf
public static <K,V> @NonNull SharedSingletonMap<K,V> orderedOf(K key, V value)
Create aSharedSingletonMap
of specifiedkey
andvalue
, which retains insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.- Parameters:
key
- keyvalue
- value- Returns:
- A SharedSingletonMap
- Throws:
NullPointerException
- if any of the arguments is null
-
unorderedOf
public static <K,V> @NonNull SharedSingletonMap<K,V> unorderedOf(K key, V value)
Create aSharedSingletonMap
of specifiedkey
andvalue
, which does not retain insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.- Parameters:
key
- keyvalue
- value- Returns:
- A SharedSingletonMap
- Throws:
NullPointerException
- if any of the arguments is null
-
orderedCopyOf
public static <K,V> @NonNull SharedSingletonMap<K,V> orderedCopyOf(Map<K,V> map)
Create aSharedSingletonMap
of specifiedkey
andvalue
, which retains insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.- Parameters:
map
- input map- Returns:
- A SharedSingletonMap
- Throws:
NullPointerException
- ifmap
is nullIllegalArgumentException
- ifmap
does not have exactly one entry
-
unorderedCopyOf
public static <K,V> @NonNull SharedSingletonMap<K,V> unorderedCopyOf(Map<K,V> map)
Create aSharedSingletonMap
from specified single-element map, which does not retain insertion order when transformed viaUnmodifiableMapPhase.toModifiableMap()
.- Parameters:
map
- input map- Returns:
- A SharedSingletonMap
- Throws:
NullPointerException
- ifmap
is nullIllegalArgumentException
- ifmap
does not have exactly one entry
-
entrySet
public final @NonNull SingletonSet<Map.Entry<K,V>> entrySet()
-
containsKey
public final boolean containsKey(Object key)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public final boolean containsValue(Object value)
- Specified by:
containsValue
in interfaceMap<K,V>
-
hashCode
public final int hashCode()
-
equals
public final boolean equals(Object obj)
-
-