Class ImmutableMapEntry<K,​V>

  • All Implemented Interfaces:
    java.io.Serializable, java.util.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 Detail

      • ImmutableMapEntry

        ImmutableMapEntry​(K key,
                          V value)
    • Method Detail

      • 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 ImmutableMapEntry[] because our checker doesn't require newly created arrays to have a element type even when they're created directly with new ImmutableMapEntry[...], so it seems silly to insist on that only here.

      • 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.