public final class MapEntry<K,V> extends AbstractMessage
Modifier and Type | Class and Description |
---|---|
static class |
MapEntry.Builder<K,V>
Builder to create
MapEntry messages. |
private static class |
MapEntry.Metadata<K,V> |
AbstractMessage.BuilderParent
Modifier and Type | Field and Description |
---|---|
private int |
cachedSerializedSize |
private K |
key |
private MapEntry.Metadata<K,V> |
metadata |
private V |
value |
memoizedSize
memoizedHashCode
Modifier | Constructor and Description |
---|---|
private |
MapEntry(Descriptors.Descriptor descriptor,
WireFormat.FieldType keyType,
K defaultKey,
WireFormat.FieldType valueType,
V defaultValue)
Create a default MapEntry instance.
|
private |
MapEntry(MapEntry.Metadata<K,V> metadata,
CodedInputStream input,
ExtensionRegistryLite extensionRegistry)
Parsing constructor.
|
private |
MapEntry(MapEntry.Metadata metadata,
K key,
V value)
Create a MapEntry with the provided key and value.
|
Modifier and Type | Method and Description |
---|---|
private void |
checkFieldDescriptor(Descriptors.FieldDescriptor field) |
java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> |
getAllFields()
Returns a collection of all the fields in this message which are set
and their corresponding values.
|
MapEntry<K,V> |
getDefaultInstanceForType()
Get an instance of the type with no fields set.
|
Descriptors.Descriptor |
getDescriptorForType()
Get the message's type's descriptor.
|
java.lang.Object |
getField(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is
not set.
|
K |
getKey() |
(package private) MapEntry.Metadata<K,V> |
getMetadata()
Returns the metadata only for experimental runtime.
|
Parser<MapEntry<K,V>> |
getParserForType()
Gets the parser for a message of the same type as this message.
|
java.lang.Object |
getRepeatedField(Descriptors.FieldDescriptor field,
int index)
Gets an element of a repeated field.
|
int |
getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Gets the number of elements of a repeated field.
|
int |
getSerializedSize()
Get the number of bytes required to encode this message.
|
UnknownFieldSet |
getUnknownFields()
Get the
UnknownFieldSet for this message. |
V |
getValue() |
boolean |
hasField(Descriptors.FieldDescriptor field)
Returns true if the given field is set.
|
boolean |
isInitialized()
Returns true if all required fields in the message and all embedded
messages are set, false otherwise.
|
private static <V> boolean |
isInitialized(MapEntry.Metadata metadata,
V value) |
MapEntry.Builder<K,V> |
newBuilderForType()
Constructs a new builder for a message of the same type as this message.
|
static <K,V> MapEntry<K,V> |
newDefaultInstance(Descriptors.Descriptor descriptor,
WireFormat.FieldType keyType,
K defaultKey,
WireFormat.FieldType valueType,
V defaultValue)
Create a default MapEntry instance.
|
MapEntry.Builder<K,V> |
toBuilder()
Constructs a builder initialized with the current message.
|
void |
writeTo(CodedOutputStream output)
Serializes the message and writes it to
output . |
compareFields, equals, findInitializationErrors, getInitializationErrorString, getOneofFieldDescriptor, hashBoolean, hashCode, hashEnum, hashEnumList, hashFields, hashLong, hasOneof, newBuilderForType, newUninitializedMessageException, toString
addAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeTo
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
toByteArray, toByteString, writeDelimitedTo, writeTo
private final K key
private final V value
private final MapEntry.Metadata<K,V> metadata
private volatile int cachedSerializedSize
private MapEntry(Descriptors.Descriptor descriptor, WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue)
private MapEntry(MapEntry.Metadata metadata, K key, V value)
private MapEntry(MapEntry.Metadata<K,V> metadata, CodedInputStream input, ExtensionRegistryLite extensionRegistry) throws InvalidProtocolBufferException
InvalidProtocolBufferException
public static <K,V> MapEntry<K,V> newDefaultInstance(Descriptors.Descriptor descriptor, WireFormat.FieldType keyType, K defaultKey, WireFormat.FieldType valueType, V defaultValue)
public K getKey()
public V getValue()
public int getSerializedSize()
MessageLite
getSerializedSize
in interface MessageLite
getSerializedSize
in class AbstractMessage
public void writeTo(CodedOutputStream output) throws java.io.IOException
MessageLite
output
. This does not
flush or close the stream.writeTo
in interface MessageLite
writeTo
in class AbstractMessage
java.io.IOException
public boolean isInitialized()
MessageLiteOrBuilder
isInitialized
in interface MessageLiteOrBuilder
isInitialized
in class AbstractMessage
public Parser<MapEntry<K,V>> getParserForType()
MessageLite
public MapEntry.Builder<K,V> newBuilderForType()
MessageLite
public MapEntry.Builder<K,V> toBuilder()
MessageLite
public MapEntry<K,V> getDefaultInstanceForType()
MessageLiteOrBuilder
getDefaultInstance()
method of generated message classes in that
this method is an abstract method of the MessageLite
interface
whereas getDefaultInstance()
is a static method of a specific
class. They return the same thing.public Descriptors.Descriptor getDescriptorForType()
MessageOrBuilder
getDescriptor()
method of generated message classes in that
this method is an abstract method of the Message
interface
whereas getDescriptor()
is a static method of a specific class.
They return the same thing.public java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFields()
MessageOrBuilder
MessageOrBuilder.getField(Descriptors.FieldDescriptor)
for each field. The map
is guaranteed to be a sorted map, so iterating over it will return fields
in order by field number.
private void checkFieldDescriptor(Descriptors.FieldDescriptor field)
public boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public java.lang.Object getField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuilder
public java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
MessageOrBuilder
public UnknownFieldSet getUnknownFields()
MessageOrBuilder
UnknownFieldSet
for this message.private static <V> boolean isInitialized(MapEntry.Metadata metadata, V value)
final MapEntry.Metadata<K,V> getMetadata()