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
,UnmodifiableMapPhase<K,
V>
public abstract sealed class SharedSingletonMap<K,V>
extends Object
implements Serializable, UnmodifiableMapPhase<K,V>
Implementation of the
Map
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 create
SharedSingletonMap
instances.
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal void
clear()
final boolean
containsKey
(Object key) final boolean
containsValue
(Object value) final @NonNull SingletonSet<Map.Entry<K,
V>> entrySet()
final boolean
final V
getEntry()
final int
hashCode()
final boolean
isEmpty()
final @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()
.final V
final void
final V
final int
size()
final 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()
.final @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 Details
-
orderedOf
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
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
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
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
-
getEntry
-
entrySet
-
keySet
-
values
-
containsKey
- Specified by:
containsKey
in interfaceMap<K,
V>
-
containsValue
- Specified by:
containsValue
in interfaceMap<K,
V>
-
get
-
size
public final int size() -
isEmpty
public final boolean isEmpty() -
put
-
remove
-
putAll
-
clear
public final void clear() -
hashCode
public final int hashCode() -
equals
-
toString
-