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

NameDescription
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
NameDescription
descriptorDescriptors.Descriptor
keyTypeWireFormat.FieldType
defaultKeyK
valueTypeWireFormat.FieldType
defaultValueV
Returns
TypeDescription
MapEntry<K,V>

Methods

getAllFields()

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

getDefaultInstanceForType()

public MapEntry<K,V> getDefaultInstanceForType()
Returns
TypeDescription
MapEntry<K,V>

getDescriptorForType()

public Descriptors.Descriptor getDescriptorForType()
Returns
TypeDescription
Descriptors.Descriptor

getField(Descriptors.FieldDescriptor field)

public Object getField(Descriptors.FieldDescriptor field)
Parameter
NameDescription
fieldDescriptors.FieldDescriptor
Returns
TypeDescription
Object

getKey()

public K getKey()
Returns
TypeDescription
K

getParserForType()

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

getRepeatedField(Descriptors.FieldDescriptor field, int index)

public Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
Parameters
NameDescription
fieldDescriptors.FieldDescriptor
indexint
Returns
TypeDescription
Object

getRepeatedFieldCount(Descriptors.FieldDescriptor field)

public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Parameter
NameDescription
fieldDescriptors.FieldDescriptor
Returns
TypeDescription
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
TypeDescription
int
Overrides

getUnknownFields()

public UnknownFieldSet getUnknownFields()
Returns
TypeDescription
UnknownFieldSet

getValue()

public V getValue()
Returns
TypeDescription
V

hasField(Descriptors.FieldDescriptor field)

public boolean hasField(Descriptors.FieldDescriptor field)
Parameter
NameDescription
fieldDescriptors.FieldDescriptor
Returns
TypeDescription
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
TypeDescription
boolean
Overrides

newBuilderForType()

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

toBuilder()

public MapEntry.Builder<K,V> toBuilder()
Returns
TypeDescription
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
NameDescription
outputCodedOutputStream
Overrides
Exceptions
TypeDescription
IOException