Package com.google.common.collect
Class ImmutableMapEntry<K,V>
- java.lang.Object
-
- com.google.common.collect.AbstractMapEntry<K,V>
-
- com.google.common.collect.ImmutableEntry<K,V>
-
- com.google.common.collect.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 ofEntry
forImmutableMap
that adds extra methods to traverse hash buckets for the key and the value. This allows reuse inRegularImmutableMap
andRegularImmutableBiMap
, which don't have to recopy the entries created by theirBuilder
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.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
ImmutableMapEntry.NonTerminalImmutableBiMapEntry<K,V>
(package private) static class
ImmutableMapEntry.NonTerminalImmutableMapEntry<K,V>
-
Field Summary
-
Fields inherited from class com.google.common.collect.ImmutableEntry
key, value
-
-
Constructor Summary
Constructors Constructor Description ImmutableMapEntry(ImmutableMapEntry<K,V> contents)
ImmutableMapEntry(K key, V value)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <K,V>
ImmutableMapEntry<K,V>[]createEntryArray(int size)
Creates anImmutableMapEntry
array to hold parameterized entries.(package private) ImmutableMapEntry<K,V>
getNextInKeyBucket()
(package private) ImmutableMapEntry<K,V>
getNextInValueBucket()
(package private) 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.-
Methods inherited from class com.google.common.collect.ImmutableEntry
getKey, getValue, setValue
-
Methods inherited from class com.google.common.collect.AbstractMapEntry
equals, hashCode, toString
-
-
-
-
Constructor Detail
-
ImmutableMapEntry
ImmutableMapEntry(ImmutableMapEntry<K,V> contents)
-
-
Method Detail
-
createEntryArray
static <K,V> ImmutableMapEntry<K,V>[] createEntryArray(int size)
Creates anImmutableMapEntry
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 withnew 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.
-
-