public final class MapFieldLite<K,V>
extends java.util.LinkedHashMap<K,V>
Modifier and Type | Field and Description |
---|---|
private static MapFieldLite |
EMPTY_MAP_FIELD |
private boolean |
isMutable |
Modifier | Constructor and Description |
---|---|
private |
MapFieldLite() |
private |
MapFieldLite(java.util.Map<K,V> mapData) |
Modifier and Type | Method and Description |
---|---|
(package private) static <K,V> int |
calculateHashCodeForMap(java.util.Map<K,V> a)
Calculates the hash code for a
Map . |
private static int |
calculateHashCodeForObject(java.lang.Object a) |
private static void |
checkForNullKeysAndValues(java.util.Map<?,?> m) |
void |
clear() |
(package private) static <K,V> java.util.Map<K,V> |
copy(java.util.Map<K,V> map)
Makes a deep copy of a
Map . |
private static java.lang.Object |
copy(java.lang.Object object) |
static <K,V> MapFieldLite<K,V> |
emptyMapField()
Returns an singleton immutable empty MapFieldLite instance.
|
private void |
ensureMutable() |
java.util.Set<java.util.Map.Entry<K,V>> |
entrySet() |
(package private) static <K,V> boolean |
equals(java.util.Map<K,V> a,
java.util.Map<K,V> b)
Checks whether two
Map s are equal. |
boolean |
equals(java.lang.Object object)
Checks whether two map fields are equal.
|
private static boolean |
equals(java.lang.Object a,
java.lang.Object b) |
int |
hashCode() |
boolean |
isMutable()
Returns whether this field can be modified.
|
void |
makeImmutable()
Makes this field immutable.
|
void |
mergeFrom(MapFieldLite<K,V> other) |
MapFieldLite<K,V> |
mutableCopy()
Returns a deep copy of this map field.
|
V |
put(K key,
V value) |
V |
put(java.util.Map.Entry<K,V> entry) |
void |
putAll(java.util.Map<? extends K,? extends V> m) |
V |
remove(java.lang.Object key) |
containsValue, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putIfAbsent, remove, replace, replace, size
private boolean isMutable
private static final MapFieldLite EMPTY_MAP_FIELD
public static <K,V> MapFieldLite<K,V> emptyMapField()
public void mergeFrom(MapFieldLite<K,V> other)
public void clear()
public V remove(java.lang.Object key)
private static void checkForNullKeysAndValues(java.util.Map<?,?> m)
private static boolean equals(java.lang.Object a, java.lang.Object b)
static <K,V> boolean equals(java.util.Map<K,V> a, java.util.Map<K,V> b)
Map
s are equal. We don't use the default equals
method of Map
because it compares by identity not by content for
byte arrays.public boolean equals(java.lang.Object object)
private static int calculateHashCodeForObject(java.lang.Object a)
static <K,V> int calculateHashCodeForMap(java.util.Map<K,V> a)
Map
. We don't use the default hash
code method of Map
because for byte arrays and protobuf enums it
use Object.hashCode()
.public int hashCode()
private static java.lang.Object copy(java.lang.Object object)
static <K,V> java.util.Map<K,V> copy(java.util.Map<K,V> map)
Map
. Immutable objects in the map will be
shared (e.g., integers, strings, immutable messages) and mutable ones will
have a copy (e.g., byte arrays, mutable messages).public MapFieldLite<K,V> mutableCopy()
public void makeImmutable()
UnsupportedOperationException
.public boolean isMutable()
private void ensureMutable()