Package com.google.protobuf
Class MapField<K,V>
- java.lang.Object
-
- com.google.protobuf.MapField<K,V>
-
public class MapField<K,V> extends java.lang.ObjectInternal representation of map fields in generated messages.This class supports accessing the map field as a
Mapto be used in generated API and also supports accessing the field as aListto 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.
-
-
Field Summary
Fields Modifier and Type Field Description static com.google.protobuf.MutabilityOracleIMMUTABLE
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()MapField<K,V>copy()Returns a deep copy of this MapField.static <K,V>
MapField<K,V>emptyMapField(MapEntry<K,V> defaultEntry)Returns an immutable empty MapField.voidensureMutable()booleanequals(java.lang.Object object)java.util.Map<K,V>getMap()Returns the content of this MapField as a read-only Map.java.util.Map<K,V>getMutableMap()Gets a mutable Map view of this MapField.inthashCode()booleanisMutable()Returns whether this field can be modified.voidmakeImmutable()Makes this list immutable.voidmergeFrom(MapField<K,V> other)static <K,V>
MapField<K,V>newMapField(MapEntry<K,V> defaultEntry)Creates a new mutable empty MapField.
-
-
-
Method Detail
-
emptyMapField
public static <K,V> MapField<K,V> emptyMapField(MapEntry<K,V> defaultEntry)
Returns an immutable empty MapField.
-
newMapField
public static <K,V> MapField<K,V> newMapField(MapEntry<K,V> defaultEntry)
Creates a new mutable empty MapField.
-
clear
public void clear()
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
makeImmutable
public void makeImmutable()
Makes this list immutable. All subsequent modifications will throw anUnsupportedOperationException.
-
isMutable
public boolean isMutable()
Returns whether this field can be modified.
-
ensureMutable
public void ensureMutable()
-
-