Class ImmutableMapEntry<K,V>

All Implemented Interfaces:
Serializable, Map.Entry<K,V>
Direct Known Subclasses:
ImmutableMapEntry.NonTerminalImmutableMapEntry

class ImmutableMapEntry<K,V> extends ImmutableEntry<K,V>
Implementation of Entry for ImmutableMap that adds extra methods to traverse hash buckets for the key and the value. This allows reuse in RegularImmutableMap and RegularImmutableBiMap, which don't have to recopy the entries created by their Builder implementations.

This base implementation has no key or value pointers, so instances of ImmutableMapEntry (but not its subclasses) can be reused when copied from one ImmutableMap to another.

  • Constructor Details

    • ImmutableMapEntry

      ImmutableMapEntry(K key, V value)
    • ImmutableMapEntry

      ImmutableMapEntry(ImmutableMapEntry<K,V> contents)
  • Method Details

    • createEntryArray

      static <K, V> ImmutableMapEntry<K,V>[] createEntryArray(int size)
      Creates an ImmutableMapEntry array to hold parameterized entries. The result must never be upcast back to ImmutableMapEntry[] (or Object[], etc.), or allowed to escape the class.

      The returned array has all its elements set to their initial null values. However, we don't declare it as @Nullable ImmutableMapEntry[] because our checker doesn't require newly created arrays to have a @Nullable element type even when they're created directly with new ImmutableMapEntry[...], so it seems silly to insist on that only here.

    • getNextInKeyBucket

      @CheckForNull ImmutableMapEntry<K,V> getNextInKeyBucket()
    • getNextInValueBucket

      @CheckForNull ImmutableMapEntry<K,V> getNextInValueBucket()
    • isReusable

      boolean isReusable()
      Returns true if this entry has no bucket links and can safely be reused as a terminal entry in a bucket in another map.