Top Description Inners Fields Constructors Methods
com.google.protobuf

public Class MapField<K, V>

extends Object
implements MutabilityOracle
Class Inheritance
All Implemented Interfaces
com.google.protobuf.MutabilityOracle
Static Imports
com.google.protobuf.Internal.checkNotNull

Internal representation of map fields in generated messages.

This class supports accessing the map field as a Map to be used in generated API and also supports accessing the field as a List to be used in reflection API. It keeps track of where the data is currently stored and do necessary conversions between map and list.

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

Thread-Safety Note

Read-only access is thread-safe. Users can call getMap() and getList() concurrently in multiple threads. If write-access is needed, all access must be synchronized.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface
private static class
private static class
MapField.MutatabilityAwareMap<K, V>

An internal map that checks for mutability before delegating.

private static enum
MapField.StorageMode

Indicates where the data of this map field is currently stored.

Field Summary

Modifier and TypeField and Description
private final MapField.Converter<K, V>
private volatile boolean
private List<Message>
private MapField.MutatabilityAwareMap<K, V>
private volatile MapField.StorageMode

Constructor Summary

AccessConstructor and Description
private
MapField(MapField.Converter<K, V> converter, MapField.StorageMode mode, Map<K, V> mapData)

private
MapField(MapEntry<K, V> defaultEntry, MapField.StorageMode mode, Map<K, V> mapData)

Method Summary

Modifier and TypeMethod and Description
public void
private Message
private MapField.MutatabilityAwareMap<K, V>
private List<Message>
private void
public MapField<K, V>
copy()

Returns a deep copy of this MapField.

public static <K, V> MapField<K, V>
emptyMapField(MapEntry<K, V> defaultEntry)

Returns an immutable empty MapField.

public void
public boolean
equals(Object
the reference object with which to compare.
object
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
pack-priv List<Message>
getList()

Gets the content of this MapField as a read-only List.

public Map<K, V>
getMap()

Returns the content of this MapField as a read-only Map.

pack-priv Message
getMapEntryMessageDefaultInstance()

Gets the default instance of the message stored in the list view of this map field.

pack-priv List<Message>
getMutableList()

Gets a mutable List view of this MapField.

public Map<K, V>
getMutableMap()

Gets a mutable Map view of this MapField.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public boolean
isMutable()

Returns whether this field can be modified.

public void
makeImmutable()

Makes this list immutable.

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

public static <K, V> MapField<K, V>
newMapField(MapEntry<K, V> defaultEntry)

Creates a new mutable empty MapField.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait