Interface ApiProviderMap<K,V>
- Type Parameters:
K
- The key type of the map, compared by reference (==
).V
- The value type of the map.
@NonExtendable
public interface ApiProviderMap<K,V>
A fast thread-safe copy-on-write map meant to be used as the backing storage for registered providers.
See
ApiLookupMap
for a usage example.
Note: This map allows very fast lock-free concurrent reads, but in exchange writes are very expensive and should not be too frequent.
Also, keys are compared by reference (==
) and not using Object.equals(java.lang.Object)
.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> ApiProviderMap<K, V> create()
Create a new instance.Return the provider to which the specified key is mapped, ornull
if this map contains no mapping for the key.putIfAbsent
(K key, V provider) If the specified key is not already associated with a provider, associate it with the given value and returnnull
, else return the current value.
-
Method Details
-
create
Create a new instance. -
get
Return the provider to which the specified key is mapped, ornull
if this map contains no mapping for the key.- Throws:
NullPointerException
- If the key is null.
-
putIfAbsent
If the specified key is not already associated with a provider, associate it with the given value and returnnull
, else return the current value.- Throws:
NullPointerException
- If the key or the provider is null.
-