Class JdkBackedImmutableMap<K,V>

java.lang.Object
com.google.common.collect.ImmutableMap<K,V>
com.google.common.collect.JdkBackedImmutableMap<K,V>
All Implemented Interfaces:
Serializable, Map<K,V>

final class JdkBackedImmutableMap<K,V> extends ImmutableMap<K,V>
Implementation of ImmutableMap backed by a JDK HashMap, which has smartness protecting against hash flooding.
  • Field Details

  • Constructor Details

  • Method Details

    • create

      static <K, V> ImmutableMap<K,V> create(int n, Map.Entry<K,V>[] entryArray, boolean throwIfDuplicateKeys)
      Creates an ImmutableMap backed by a JDK HashMap. Used when probable hash flooding is detected. This implementation may replace the entries in entryArray with its own entry objects (though they will have the same key/value contents), and will take ownership of entryArray.
    • size

      public int size()
    • get

      @CheckForNull public V get(@CheckForNull Object key)
      Specified by:
      get in interface Map<K,V>
      Specified by:
      get in class ImmutableMap<K,V>
    • createEntrySet

      ImmutableSet<Map.Entry<K,V>> createEntrySet()
      Specified by:
      createEntrySet in class ImmutableMap<K,V>
    • forEach

      public void forEach(BiConsumer<? super K,? super V> action)
    • createKeySet

      ImmutableSet<K> createKeySet()
      Specified by:
      createKeySet in class ImmutableMap<K,V>
    • createValues

      ImmutableCollection<V> createValues()
      Specified by:
      createValues in class ImmutableMap<K,V>
    • isPartialView

      boolean isPartialView()
      Specified by:
      isPartialView in class ImmutableMap<K,V>
    • writeReplace

      Object writeReplace()
      Description copied from class: ImmutableMap
      Returns a serializable form of this object. Non-public subclasses should not override this method. Publicly-accessible subclasses must override this method and should return a subclass of SerializedForm whose readResolve() method returns objects of the subclass type.
      Overrides:
      writeReplace in class ImmutableMap<K,V>