Package com.google.protobuf
Class MapFieldLite<K,V>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- com.google.protobuf.MapFieldLite<K,V>
-
- All Implemented Interfaces:
Serializable,Cloneable,Map<K,V>
public final class MapFieldLite<K,V> extends HashMap<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
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Removes all of the mappings from this map.static <K,V>
MapFieldLite<K,V>emptyMapField()Returns a singleton immutable empty MapFieldLite instance.Set<Map.Entry<K,V>>entrySet()Returns aSetview of the mappings contained in this map.booleanequals(Object object)Checks whether two map fields are equal.inthashCode()Returns the hash code value for this map.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(Map.Entry<K,V> entry)Vput(K key, V value)Associates the specified value with the specified key in this map.voidputAll(Map<? extends K,? extends V> m)Copies all of the mappings from the specified map to this map.Vremove(Object key)Removes the mapping for the specified key from this map if present.-
Methods inherited from class java.util.HashMap
clone, containsKey, containsValue, get, isEmpty, keySet, size, values
-
Methods inherited from class java.util.AbstractMap
toString
-
-
-
-
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)
-
entrySet
public Set<Map.Entry<K,V>> entrySet()
Description copied from class:HashMapReturns aSetview of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's ownremoveoperation, or through thesetValueoperation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via theIterator.remove,Set.remove,removeAll,retainAllandclearoperations. It does not support theaddoraddAlloperations.
-
clear
public void clear()
Description copied from class:HashMapRemoves all of the mappings from this map. The map will be empty after this call returns.
-
put
@CanIgnoreReturnValue public V put(K key, V value)
Description copied from class:HashMapAssociates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.- Specified by:
putin interfaceMap<K,V>- Overrides:
putin classHashMap<K,V>- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with
key, ornullif there was no mapping forkey. (Anullreturn can also indicate that the map previously associatednullwithkey.)
-
putAll
public void putAll(Map<? extends K,? extends V> m)
Description copied from class:HashMapCopies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map.
-
remove
@CanIgnoreReturnValue public V remove(Object key)
Description copied from class:HashMapRemoves the mapping for the specified key from this map if present.- Specified by:
removein interfaceMap<K,V>- Overrides:
removein classHashMap<K,V>- Parameters:
key- key whose mapping is to be removed from the map- Returns:
- the previous value associated with
key, ornullif there was no mapping forkey. (Anullreturn can also indicate that the map previously associatednullwithkey.)
-
equals
public boolean equals(Object object)
Checks whether two map fields are equal.- Specified by:
equalsin interfaceMap<K,V>- Overrides:
equalsin classAbstractMap<K,V>- Parameters:
object- object to be compared for equality with this map- Returns:
trueif the specified object is equal to this map- See Also:
Object.hashCode(),HashMap
-
hashCode
public int hashCode()
Description copied from class:AbstractMapReturns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map'sentrySet()view. This ensures thatm1.equals(m2)implies thatm1.hashCode()==m2.hashCode()for any two mapsm1andm2, as required by the general contract ofObject.hashCode().This implementation iterates over
entrySet(), callinghashCode()on each element (entry) in the set, and adding up the results.- Specified by:
hashCodein interfaceMap<K,V>- Overrides:
hashCodein classAbstractMap<K,V>- Returns:
- the hash code value for this map
- See Also:
Map.Entry.hashCode(),Object.equals(Object),Set.equals(Object)
-
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.
-
-