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 Type
    Method
    Description
    static <K, V> ApiProviderMap<K,V>
    Create a new instance.
    get(K key)
    Return the provider to which the specified key is mapped, or null 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 return null, else return the current value.
  • Method Details

    • create

      static <K, V> ApiProviderMap<K,V> create()
      Create a new instance.
    • get

      @Nullable V get(K key)
      Return the provider to which the specified key is mapped, or null if this map contains no mapping for the key.
      Throws:
      NullPointerException - If the key is null.
    • putIfAbsent

      V putIfAbsent(K key, V provider)
      If the specified key is not already associated with a provider, associate it with the given value and return null, else return the current value.
      Throws:
      NullPointerException - If the key or the provider is null.