Top Description Fields Constructors Methods
com.google.protobuf

public final Class MapFieldLite<K, V>

extends LinkedHashMap<K, V>
Class Inheritance
Static Imports
com.google.protobuf.Internal.checkNotNull

Internal representation of map fields in generated lite-runtime messages.

This class is a protobuf implementation detail. Users shouldn't use this class directly.

Field Summary

Modifier and TypeField and Description
private static final MapFieldLite<K, V>
private boolean

Constructor Summary

AccessConstructor and Description
private
private
MapFieldLite(Map<K, V> mapData)

Method Summary

Modifier and TypeMethod and Description
pack-priv static <K, V> int
calculateHashCodeForMap(Map<K, V> a)

Calculates the hash code for a Map.

private static int
private static void
public void
clear()

Overrides java.util.LinkedHashMap.clear.

Implements java.util.Map.clear.

Removes all of the mappings from this map (optional operation).
private static Object
copy(Object object)

pack-priv static <K, V> Map<K, V>
copy(Map<K, V> map)

Makes a deep copy of a Map.

public static <K, V> MapFieldLite<K, V>
emptyMapField()

Returns an singleton immutable empty MapFieldLite instance.

private void
public Set<Map.Entry<K, V>>
entrySet()

Overrides java.util.LinkedHashMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.
private static boolean
pack-priv static <K, V> boolean
equals(Map<K, V> a, Map<K, V> b)

Checks whether two Maps are equal.

public boolean
equals(Object
object to be compared for equality with this map
object
)

Overrides java.util.AbstractMap.equals.

Implements java.util.Map.equals.

Checks whether two map fields are equal.
public int
hashCode()

Overrides java.util.AbstractMap.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.
public boolean
isMutable()

Returns whether this field can be modified.

public void
makeImmutable()

Makes this field immutable.

public void
mergeFrom(MapFieldLite<K, V> other)

public MapFieldLite<K, V>
mutableCopy()

Returns a deep copy of this map field.

public V
put(K
key with which the specified value is to be associated
key
,
V
value to be associated with the specified key
value
)

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation).
public V
put(Map.Entry<K, V> entry)

public void
putAll(Map<? extends K, ? extends V>
mappings to be stored in this map
m
)

Overrides java.util.HashMap.putAll.

Implements java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation).
public V
remove(Object
key whose mapping is to be removed from the map
key
)

Overrides java.util.HashMap.remove.

Implements java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation).
Inherited from java.util.LinkedHashMap:
containsValueforEachgetgetOrDefaultkeySetnewLinkedHashMapputFirstputLastremoveEldestEntryreplaceAllreversedsequencedEntrySetsequencedKeySetsequencedValuesvalues

Field Detail

EMPTY_MAP_FIELDback to summary
private static final MapFieldLite<K, V> EMPTY_MAP_FIELD
Annotations
@SuppressWarnings:rawtypes, unchecked
isMutableback to summary
private boolean isMutable

Constructor Detail

MapFieldLiteback to summary
private MapFieldLite()
MapFieldLiteback to summary
private MapFieldLite(Map<K, V> mapData)

Method Detail

calculateHashCodeForMapback to summary
pack-priv static <K, V> int calculateHashCodeForMap(Map<K, V> a)

Calculates the hash code for a Map. We don't use the default hash code method of Map because for byte arrays and protobuf enums it use Object#hashCode().

calculateHashCodeForObjectback to summary
private static int calculateHashCodeForObject(Object a)
checkForNullKeysAndValuesback to summary
private static void checkForNullKeysAndValues(Map<?, ?> m)
clearback to summary
public void clear()

Overrides java.util.LinkedHashMap.clear.

Implements java.util.Map.clear.

Doc from java.util.LinkedHashMap.clear.

Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.

Annotations
@Override
copyback to summary
private static Object copy(Object object)
copyback to summary
pack-priv static <K, V> Map<K, V> copy(Map<K, V> map)

Makes a deep copy of a 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).

Annotations
@SuppressWarnings:unchecked
emptyMapFieldback to summary
public static <K, V> MapFieldLite<K, V> emptyMapField()

Returns an singleton immutable empty MapFieldLite instance.

Annotations
@SuppressWarnings:unchecked, cast
ensureMutableback to summary
private void ensureMutable()
entrySetback to summary
public Set<Map.Entry<K, V>> entrySet()

Overrides java.util.LinkedHashMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.LinkedHashMap.entrySet.

Returns a Set view of the mappings contained in this map. The encounter order of the view matches the encounter order of entries of 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 own remove operation, or through the setValue operation 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 the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations. Its Spliterator typically provides faster sequential performance but much poorer parallel performance than that of HashMap.

Returns:Set<Map.Entry<K, V>>

a set view of the mappings contained in this map

Annotations
@SuppressWarnings:unchecked, cast
@Override
equalsback to summary
private static boolean equals(Object a, Object b)
equalsback to summary
pack-priv static <K, V> boolean equals(Map<K, V> a, Map<K, V> b)

Checks whether two Maps are equal. We don't use the default equals method of Map because it compares by identity not by content for byte arrays.

equalsback to summary
public boolean equals(Object object)

Overrides java.util.AbstractMap.equals.

Implements java.util.Map.equals.

Checks whether two map fields are equal.

Parameters
object:Object

Doc from java.util.Map.equals.

object to be compared for equality with this map

Returns:boolean

Doc from java.util.Map.equals.

true if the specified object is equal to this map

Annotations
@SuppressWarnings:unchecked
@Override
hashCodeback to summary
public int hashCode()

Overrides java.util.AbstractMap.hashCode.

Implements java.util.Map.hashCode.

Doc from java.util.Map.hashCode.

Returns 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's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two maps m1 and m2, as required by the general contract of Object#hashCode.

Returns:int

the hash code value for this map

Annotations
@Override
isMutableback to summary
public boolean isMutable()

Returns whether this field can be modified.

makeImmutableback to summary
public void makeImmutable()

Makes this field immutable. All subsequent modifications will throw an UnsupportedOperationException.

mergeFromback to summary
public void mergeFrom(MapFieldLite<K, V> other)
mutableCopyback to summary
public MapFieldLite<K, V> mutableCopy()

Returns a deep copy of this map field.

putback to summary
public V put(K key, V value)

Overrides java.util.HashMap.put.

Implements java.util.Map.put.

Doc from java.util.Map.put.

Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Parameters
key:K

key with which the specified value is to be associated

value:V

value to be associated with the specified key

Returns:V

the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key, if the implementation supports null values.)

Annotations
@Override
putback to summary
public V put(Map.Entry<K, V> entry)
putAllback to summary
public void putAll(Map<? extends K, ? extends V> m)

Overrides java.util.HashMap.putAll.

Implements java.util.Map.putAll.

Doc from java.util.Map.putAll.

Copies all of the mappings from the specified map to this map (optional operation). The effect of this call is equivalent to that of calling put(k, v) on this map once for each mapping from key k to value v in the specified map. The behavior of this operation is undefined if the specified map is modified while the operation is in progress. If the specified map has a defined encounter order, processing of its mappings generally occurs in that order.

Parameters
m:Map<? extends K, ? extends V>

mappings to be stored in this map

Annotations
@Override
removeback to summary
public V remove(Object key)

Overrides java.util.HashMap.remove.

Implements java.util.Map.remove.

Doc from java.util.Map.remove.

Removes the mapping for a key from this map if it is present (optional operation). More formally, if this map contains a mapping from key k to value v such that Objects.equals(key, k), that mapping is removed. (The map can contain at most one such mapping.)

Returns the value to which this map previously associated the key, or null if the map contained no mapping for the key.

If this map permits null values, then a return value of null does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to null.

The map will not contain a mapping for the specified key once the call returns.

Parameters
key:Object

key whose mapping is to be removed from the map

Returns:V

the previous value associated with key, or null if there was no mapping for key.

Annotations
@Override