Package com.google.protobuf
Class MapFieldLite<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<K,V>
-
- com.google.protobuf.MapFieldLite<K,V>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<K,V>
public final class MapFieldLite<K,V> extends java.util.LinkedHashMap<K,V>Internal representation of map fields in generated lite-runtime messages.This class is a protobuf implementation detail. Users shouldn't use this class directly.
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static MapFieldLite<?,?>EMPTY_MAP_FIELDprivate booleanisMutable
-
Constructor Summary
Constructors Modifier Constructor Description privateMapFieldLite()privateMapFieldLite(java.util.Map<K,V> mapData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static <K,V>
intcalculateHashCodeForMap(java.util.Map<K,V> a)Calculates the hash code for aMap.private static intcalculateHashCodeForObject(java.lang.Object a)private static voidcheckForNullKeysAndValues(java.util.Map<?,?> m)voidclear()private static java.lang.Objectcopy(java.lang.Object object)(package private) static <K,V>
java.util.Map<K,V>copy(java.util.Map<K,V> map)Makes a deep copy of aMap.static <K,V>
MapFieldLite<K,V>emptyMapField()Returns a singleton immutable empty MapFieldLite instance.private voidensureMutable()java.util.Set<java.util.Map.Entry<K,V>>entrySet()booleanequals(java.lang.Object object)Checks whether two map fields are equal.private static booleanequals(java.lang.Object a, java.lang.Object b)(package private) static <K,V>
booleanequals(java.util.Map<K,V> a, java.util.Map<K,V> b)Checks whether twoMaps are equal.inthashCode()booleanisMutable()Returns whether this field can be modified.voidmakeImmutable()Makes this field immutable.voidmergeFrom(MapFieldLite<K,V> other)MapFieldLite<K,V>mutableCopy()Returns a deep copy of this map field.Vput(java.util.Map.Entry<K,V> entry)Vput(K key, V value)voidputAll(java.util.Map<? extends K,? extends V> m)Vremove(java.lang.Object key)-
Methods inherited from class java.util.LinkedHashMap
containsValue, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, putIfAbsent, remove, replace, replace, size
-
-
-
-
Field Detail
-
isMutable
private boolean isMutable
-
EMPTY_MAP_FIELD
private static final MapFieldLite<?,?> EMPTY_MAP_FIELD
-
-
Method Detail
-
emptyMapField
public static <K,V> MapFieldLite<K,V> emptyMapField()
Returns a singleton immutable empty MapFieldLite instance.
-
mergeFrom
public void mergeFrom(MapFieldLite<K,V> other)
-
clear
public void clear()
-
remove
public V remove(java.lang.Object key)
-
checkForNullKeysAndValues
private static void checkForNullKeysAndValues(java.util.Map<?,?> m)
-
equals
private static boolean equals(java.lang.Object a, java.lang.Object b)
-
equals
static <K,V> boolean equals(java.util.Map<K,V> a, java.util.Map<K,V> b)Checks whether twoMaps are equal. We don't use the default equals method ofMapbecause it compares by identity not by content for byte arrays.
-
equals
public boolean equals(java.lang.Object object)
Checks whether two map fields are equal.
-
calculateHashCodeForObject
private static int calculateHashCodeForObject(java.lang.Object a)
-
calculateHashCodeForMap
static <K,V> int calculateHashCodeForMap(java.util.Map<K,V> a)
Calculates the hash code for aMap. We don't use the default hash code method ofMapbecause for byte arrays and protobuf enums it useObject.hashCode().
-
hashCode
public int hashCode()
-
copy
private static java.lang.Object copy(java.lang.Object object)
-
copy
static <K,V> java.util.Map<K,V> copy(java.util.Map<K,V> map)
Makes a deep copy of aMap. 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).
-
mutableCopy
public MapFieldLite<K,V> mutableCopy()
Returns a deep copy of this map field.
-
makeImmutable
public void makeImmutable()
Makes this field immutable. All subsequent modifications will throw anUnsupportedOperationException.
-
isMutable
public boolean isMutable()
Returns whether this field can be modified.
-
ensureMutable
private void ensureMutable()
-
-