Top Description Fields Constructors Methods
com.google.common.collect

pack-priv final Class JdkBackedImmutableMap<K, V>

extends ImmutableMap<K, V>
Class Inheritance
Annotations
@GwtCompatible
emulated:true
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkNotNull, com.google.common.collect.RegularImmutableMap.makeImmutable, java.util.Objects.requireNonNull

Implementation of ImmutableMap backed by a JDK HashMap, which has smartness protecting against hash flooding.

Field Summary

Modifier and TypeField and Description
private final transient Map<K, V>
private final transient ImmutableList<Map.Entry<K, V>>
Inherited from com.google.common.collect.ImmutableMap:
EMPTY_ENTRY_ARRAY

Constructor Summary

AccessConstructor and Description
pack-priv
JdkBackedImmutableMap(Map<K, V> delegateMap, ImmutableList<Map.Entry<K, V>> entries)

Method Summary

Modifier and TypeMethod and Description
pack-priv static <K, V> ImmutableMap<K, V>
create(int n, @Nullable Map.Entry<K, V>[] entryArray, boolean throwIfDuplicateKeys)

Creates an ImmutableMap backed by a JDK HashMap.

pack-priv ImmutableSet<Map.Entry<K, V>>
pack-priv ImmutableSet<K>
pack-priv ImmutableCollection<V>
public void
forEach(BiConsumer<? super K, ? super V>
The action to be performed for each entry
action
)

Overrides default java.util.Map.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception.
public V
get(Object
the key whose associated value is to be returned
key
)

Implements abstract com.google.common.collect.ImmutableMap.get.

Implements java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
pack-priv boolean
public int
size()

Implements java.util.Map.size.

Returns the number of key-value mappings in this map.
pack-priv Object
writeReplace()

Overrides com.google.common.collect.ImmutableMap.writeReplace.

Returns a serializable form of this object.
Inherited from com.google.common.collect.ImmutableMap:
asMultimapbuilderbuilderWithExpectedSizecheckNoConflictclearcomputecomputeIfAbsentcomputeIfPresentconflictExceptioncontainsKeycontainsValuecopyOfcopyOfentryOfentrySetequalsgetOrDefaulthashCodeisEmptyisHashCodeFastkeyIteratorkeySetkeySpliteratormergeofofofofofofofofofofofofEntriesputputAllputIfAbsentremoveremovereplacereplacereplaceAlltoImmutableMaptoImmutableMaptoStringvalues

Field Detail

delegateMapback to summary
private final transient Map<K, V> delegateMap
entriesback to summary
private final transient ImmutableList<Map.Entry<K, V>> entries

Constructor Detail

JdkBackedImmutableMapback to summary
pack-priv JdkBackedImmutableMap(Map<K, V> delegateMap, ImmutableList<Map.Entry<K, V>> entries)

Method Detail

createback to summary
pack-priv static <K, V> ImmutableMap<K, V> create(int n, @Nullable 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.

createEntrySetback to summary
pack-priv ImmutableSet<Map.Entry<K, V>> createEntrySet()

Implements abstract com.google.common.collect.ImmutableMap.createEntrySet.

Annotations
@Override
createKeySetback to summary
pack-priv ImmutableSet<K> createKeySet()

Implements abstract com.google.common.collect.ImmutableMap.createKeySet.

Annotations
@Override
createValuesback to summary
pack-priv ImmutableCollection<V> createValues()

Implements abstract com.google.common.collect.ImmutableMap.createValues.

Annotations
@Override
forEachback to summary
public void forEach(BiConsumer<? super K, ? super V> action)

Overrides default java.util.Map.forEach.

Doc from java.util.Map.forEach.

Performs the given action for each entry in this map until all entries have been processed or the action throws an exception. Unless otherwise specified by the implementing class, actions are performed in the order of entry set iteration (if an iteration order is specified.) Exceptions thrown by the action are relayed to the caller.

Parameters
action:BiConsumer<? super K, ? super V>

The action to be performed for each entry

Annotations
@Override
getback to summary
public V get(Object key)

Implements abstract com.google.common.collect.ImmutableMap.get.

Implements java.util.Map.get.

Doc from java.util.Map.get.

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that Objects.equals(key, k), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)

If this map permits null values, then a return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.

Parameters
key:Object

the key whose associated value is to be returned

Returns:V

the value to which the specified key is mapped, or null if this map contains no mapping for the key

Annotations
@Override
@CheckForNull
isPartialViewback to summary
pack-priv boolean isPartialView()

Implements abstract com.google.common.collect.ImmutableMap.isPartialView.

Annotations
@Override
sizeback to summary
public int size()

Implements java.util.Map.size.

Doc from java.util.Map.size.

Returns the number of key-value mappings in this map. If the map contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of key-value mappings in this map

Annotations
@Override
writeReplaceback to summary
pack-priv Object writeReplace()

Overrides com.google.common.collect.ImmutableMap.writeReplace.

Doc from com.google.common.collect.ImmutableMap.writeReplace.

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.

Annotations
@SuppressWarnings:RedundantOverride
@Override
@J2ktIncompatible
@GwtIncompatible