Class MapEntry<K,V> (3.19.4)

public final class MapEntry<K,V> extends AbstractMessage

Implements MapEntry messages.

In reflection API, map fields will be treated as repeated message fields and each map entry is accessed as a message. This MapEntry class is used to represent these map entry messages in reflection API.

Protobuf internal. Users shouldn't use this class.

Type Parameters

Name Description
K
V

Static Methods

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

public static MapEntry<K,V> <K,V>newDefaultInstance(Descriptors.Descriptor descriptor, WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue)

Create a default MapEntry instance. A default MapEntry instance should be created only once for each map entry message type. Generated code should store the created default instance and use it later to create new MapEntry messages of the same type.

Parameters
Name Description
descriptor Descriptors.Descriptor
keyType WireFormat.FieldType
defaultKey K
valueType WireFormat.FieldType
defaultValue V
Returns
Type Description
MapEntry<K,V>

Methods

getAllFields()

public Map<Descriptors.FieldDescriptor,Object> getAllFields()
Returns
Type Description
Map<FieldDescriptor,Object>

getDefaultInstanceForType()

public MapEntry<K,V> getDefaultInstanceForType()
Returns
Type Description
MapEntry<K,V>

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
Type Description
Descriptors.Descriptor

getField(Descriptors.FieldDescriptor field)

public Object getField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field Descriptors.FieldDescriptor
Returns
Type Description
Object

getKey()

public K getKey()
Returns
Type Description
K

getParserForType()

public Parser<MapEntry<K,V>> getParserForType()
Returns
Type Description
Parser<MapEntry<K,V>>

getRepeatedField(Descriptors.FieldDescriptor field, int index)

public Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
Parameters
Name Description
field Descriptors.FieldDescriptor
index int
Returns
Type Description
Object

getRepeatedFieldCount(Descriptors.FieldDescriptor field)

public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Parameter
Name Description
field Descriptors.FieldDescriptor
Returns
Type Description
int

getSerializedSize()

public int getSerializedSize()

Get the number of bytes required to encode this message. The result is only computed on the first call and memoized after that.

If this message requires more than Integer.MAX_VALUE bytes to encode, the return value will be smaller than the actual number of bytes required and might be negative.

Returns
Type Description
int
Overrides

getUnknownFields()

public UnknownFieldSet getUnknownFields()
Returns
Type Description
UnknownFieldSet

getValue()

public V getValue()
Returns
Type Description
V

hasField(Descriptors.FieldDescriptor field)

public boolean hasField(Descriptors.FieldDescriptor field)
Parameter
Name Description
field Descriptors.FieldDescriptor
Returns
Type Description
boolean

isInitialized()

public boolean isInitialized()

Returns true if all required fields in the message and all embedded messages are set, false otherwise.

See also: MessageOrBuilder#getInitializationErrorString()

Returns
Type Description
boolean
Overrides

newBuilderForType()

public MapEntry.Builder<K,V> newBuilderForType()
Returns
Type Description
Builder<K,V>

toBuilder()

public MapEntry.Builder<K,V> toBuilder()
Returns
Type Description
Builder<K,V>

writeTo(CodedOutputStream output)

public void writeTo(CodedOutputStream output)

Serializes the message and writes it to output. This does not flush or close the stream.

Parameter
Name Description
output CodedOutputStream
Overrides
Exceptions
Type Description
IOException