Class MapEntryLite<K,V> (3.19.4)

public class MapEntryLite<K,V>

Implements the lite version of map entry messages.

This class serves as an utility class to help do serialization/parsing of map entries. It's used in generated code and also in the full version MapEntry message.

Protobuf internal. Users shouldn't use.

Inheritance

java.lang.Object > MapEntryLite<K,V>

Type Parameters

Name Description
K
V

Static Methods

<K,V>newDefaultInstance(WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue)

public static MapEntryLite<K,V> <K,V>newDefaultInstance(WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue)

Creates a default MapEntryLite message instance.

This method is used by generated code to create the default instance for a map entry message. The created default instance should be used to create new map entry messages of the same type. For each map entry message, only one default instance should be created.

Parameters
Name Description
keyType WireFormat.FieldType
defaultKey K
valueType WireFormat.FieldType
defaultValue V
Returns
Type Description
MapEntryLite<K,V>

Methods

computeMessageSize(int fieldNumber, K key, V value)

public int computeMessageSize(int fieldNumber, K key, V value)

Computes the message size for the provided key and value as though they were wrapped by a MapEntryLite. This helper method avoids allocation of a MapEntryLite built with a key and value and is called from generated code directly.

Parameters
Name Description
fieldNumber int
key K
value V
Returns
Type Description
int

getKey()

public K getKey()
Returns
Type Description
K

getValue()

public V getValue()
Returns
Type Description
V

parseEntry(ByteString bytes, ExtensionRegistryLite extensionRegistry)

public Map.Entry<K,V> parseEntry(ByteString bytes, ExtensionRegistryLite extensionRegistry)

Parses an entry off of the input as a Map.Entry. This helper requires an allocation so using #parseInto is preferred if possible.

Parameters
Name Description
bytes ByteString
extensionRegistry ExtensionRegistryLite
Returns
Type Description
Entry<K,V>
Exceptions
Type Description
IOException

parseInto(MapFieldLite<K,V> map, CodedInputStream input, ExtensionRegistryLite extensionRegistry)

public void parseInto(MapFieldLite<K,V> map, CodedInputStream input, ExtensionRegistryLite extensionRegistry)

Parses an entry off of the input into the map. This helper avoids allocation of a MapEntryLite by parsing directly into the provided MapFieldLite.

Parameters
Name Description
map MapFieldLite<K,V>
input CodedInputStream
extensionRegistry ExtensionRegistryLite
Exceptions
Type Description
IOException

serializeTo(CodedOutputStream output, int fieldNumber, K key, V value)

public void serializeTo(CodedOutputStream output, int fieldNumber, K key, V value)

Serializes the provided key and value as though they were wrapped by a MapEntryLite to the output stream. This helper method avoids allocation of a MapEntryLite built with a key and value and is called from generated code directly.

Parameters
Name Description
output CodedOutputStream
fieldNumber int
key K
value V
Exceptions
Type Description
IOException