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 |
memoizedSizememoizedHashCode| 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, getMemoizedSerializedSize, getOneofFieldDescriptor, hashBoolean, hashCode, hashEnum, hashEnumList, hashFields, hashLong, hasOneof, newBuilderForType, newUninitializedMessageException, setMemoizedSerializedSize, toStringaddAll, addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waittoByteArray, toByteString, writeDelimitedTo, writeToprivate 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
InvalidProtocolBufferExceptionpublic 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()
MessageLitegetSerializedSize in interface MessageLitegetSerializedSize in class AbstractMessagepublic void writeTo(CodedOutputStream output) throws java.io.IOException
MessageLiteoutput. This does not
flush or close the stream.writeTo in interface MessageLitewriteTo in class AbstractMessagejava.io.IOExceptionpublic boolean isInitialized()
MessageLiteOrBuilderisInitialized in interface MessageLiteOrBuilderisInitialized in class AbstractMessagepublic Parser<MapEntry<K,V>> getParserForType()
MessageLitepublic MapEntry.Builder<K,V> newBuilderForType()
MessageLitepublic MapEntry.Builder<K,V> toBuilder()
MessageLitepublic MapEntry<K,V> getDefaultInstanceForType()
MessageLiteOrBuildergetDefaultInstance() 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()
MessageOrBuildergetDescriptor() 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()
MessageOrBuilderMessageOrBuilder.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)
MessageOrBuilderpublic java.lang.Object getField(Descriptors.FieldDescriptor field)
MessageOrBuilderpublic int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuilderpublic java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
MessageOrBuilderpublic UnknownFieldSet getUnknownFields()
MessageOrBuilderUnknownFieldSet for this message.private static <V> boolean isInitialized(MapEntry.Metadata metadata, V value)
final MapEntry.Metadata<K,V> getMetadata()