public abstract static class GeneratedMessageV3.ExtendableMessage<MessageType extends GeneratedMessageV3.ExtendableMessage> extends GeneratedMessageV3 implements GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType>
This class implements type-safe accessors for extensions. They
implement all the same operations that you can do with normal fields --
e.g. "has", "get", and "getCount" -- but for extensions. The extensions
are identified using instances of the class GeneratedMessage.GeneratedExtension;
the protocol compiler generates a static instance of this class for every
extension in its input. Through the magic of generics, all is made
type-safe.
For example, imagine you have the .proto file:
option java_class = "MyProto";
message Foo {
extensions 1000 to max;
}
extend Foo {
optional int32 bar;
}
Then you might write code like:
MyProto.Foo foo = getFoo(); int i = foo.getExtension(MyProto.bar);
See also GeneratedMessageV3.ExtendableBuilder.
| Modifier and Type | Class and Description |
|---|---|
protected class |
GeneratedMessageV3.ExtendableMessage.ExtensionWriter
Used by subclasses to serialize extensions.
|
GeneratedMessageV3.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>, GeneratedMessageV3.BuilderParent, GeneratedMessageV3.ExtendableBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage,BuilderType extends GeneratedMessageV3.ExtendableBuilder<MessageType,BuilderType>>, GeneratedMessageV3.ExtendableMessage<MessageType extends GeneratedMessageV3.ExtendableMessage>, GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>, GeneratedMessageV3.FieldAccessorTablealwaysUseFieldBuilders, unknownFieldsmemoizedSizememoizedHashCode| Modifier | Constructor and Description |
|---|---|
protected |
GeneratedMessageV3.ExtendableMessage() |
protected |
GeneratedMessageV3.ExtendableMessage(GeneratedMessageV3.ExtendableBuilder<MessageType,?> builder) |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
extensionsAreInitialized()
Called by subclasses to check if all extensions are initialized.
|
protected int |
extensionsSerializedSize()
Called by subclasses to compute the size of extensions.
|
protected int |
extensionsSerializedSizeAsMessageSet() |
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.
|
java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> |
getAllFieldsRaw()
Returns a collection of all the fields in this message which are set
and their corresponding values.
|
<Type> Type |
getExtension(Extension<MessageType,java.util.List<Type>> extension,
int index)
Get one element of a repeated extension.
|
<Type> Type |
getExtension(Extension<MessageType,Type> extension)
Get the value of an extension.
|
<Type> Type |
getExtension(ExtensionLite<MessageType,java.util.List<Type>> extensionLite,
int index)
Get one element of a repeated extension.
|
<Type> Type |
getExtension(ExtensionLite<MessageType,Type> extensionLite)
Get the value of an extension.
|
<Type> Type |
getExtension(GeneratedMessage.GeneratedExtension<MessageType,java.util.List<Type>> extension,
int index)
Get one element of a repeated extension.
|
<Type> Type |
getExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
Get the value of an extension.
|
<Type> int |
getExtensionCount(Extension<MessageType,java.util.List<Type>> extension)
Get the number of elements in a repeated extension.
|
<Type> int |
getExtensionCount(ExtensionLite<MessageType,java.util.List<Type>> extensionLite)
Get the number of elements in a repeated extension.
|
<Type> int |
getExtensionCount(GeneratedMessage.GeneratedExtension<MessageType,java.util.List<Type>> extension)
Get the number of elements in a repeated extension.
|
protected java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> |
getExtensionFields() |
java.lang.Object |
getField(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is
not set.
|
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.
|
<Type> boolean |
hasExtension(Extension<MessageType,Type> extension)
Check if a singular extension is present.
|
<Type> boolean |
hasExtension(ExtensionLite<MessageType,Type> extensionLite)
Check if a singular extension is present.
|
<Type> boolean |
hasExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
Check if a singular extension is present.
|
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.
|
protected void |
makeExtensionsImmutable()
Used by parsing constructors in generated classes.
|
protected GeneratedMessageV3.ExtendableMessage.ExtensionWriter |
newExtensionWriter() |
protected GeneratedMessageV3.ExtendableMessage.ExtensionWriter |
newMessageSetExtensionWriter() |
protected boolean |
parseUnknownField(CodedInputStream input,
UnknownFieldSet.Builder unknownFields,
ExtensionRegistryLite extensionRegistry,
int tag)
Called by subclasses to parse an unknown field.
|
computeStringSize, computeStringSizeNoTag, getDescriptorForType, getOneofFieldDescriptor, getParserForType, getSerializedSize, getUnknownFields, hasOneof, internalGetFieldAccessorTable, internalGetMapField, newBuilderForType, newBuilderForType, parseDelimitedWithIOException, parseDelimitedWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTag, writeToequals, findInitializationErrors, getInitializationErrorString, hashBoolean, hashCode, hashEnum, hashEnumList, hashFields, hashLong, toStringaddAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetDefaultInstanceForTypefindInitializationErrors, getDescriptorForType, getInitializationErrorString, getOneofFieldDescriptor, getUnknownFields, hasOneofnewBuilderForType, toBuildertoByteArray, toByteString, writeDelimitedTo, writeToprotected GeneratedMessageV3.ExtendableMessage()
protected GeneratedMessageV3.ExtendableMessage(GeneratedMessageV3.ExtendableBuilder<MessageType,?> builder)
public final <Type> boolean hasExtension(ExtensionLite<MessageType,Type> extensionLite)
hasExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> int getExtensionCount(ExtensionLite<MessageType,java.util.List<Type>> extensionLite)
getExtensionCount in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> Type getExtension(ExtensionLite<MessageType,Type> extensionLite)
getExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> Type getExtension(ExtensionLite<MessageType,java.util.List<Type>> extensionLite, int index)
getExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> boolean hasExtension(Extension<MessageType,Type> extension)
hasExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> boolean hasExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
hasExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> int getExtensionCount(Extension<MessageType,java.util.List<Type>> extension)
getExtensionCount in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> int getExtensionCount(GeneratedMessage.GeneratedExtension<MessageType,java.util.List<Type>> extension)
getExtensionCount in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> Type getExtension(Extension<MessageType,Type> extension)
getExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> Type getExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
getExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> Type getExtension(Extension<MessageType,java.util.List<Type>> extension, int index)
getExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>public final <Type> Type getExtension(GeneratedMessage.GeneratedExtension<MessageType,java.util.List<Type>> extension, int index)
getExtension in interface GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends GeneratedMessageV3.ExtendableMessage>protected boolean extensionsAreInitialized()
public boolean isInitialized()
MessageLiteOrBuilderisInitialized in interface MessageLiteOrBuilderisInitialized in class GeneratedMessageV3protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws java.io.IOException
GeneratedMessageV3parseUnknownField in class GeneratedMessageV3true unless the tag is an end-group tag.java.io.IOExceptionprotected void makeExtensionsImmutable()
makeExtensionsImmutable in class GeneratedMessageV3protected GeneratedMessageV3.ExtendableMessage.ExtensionWriter newExtensionWriter()
protected GeneratedMessageV3.ExtendableMessage.ExtensionWriter newMessageSetExtensionWriter()
protected int extensionsSerializedSize()
protected int extensionsSerializedSizeAsMessageSet()
protected java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getExtensionFields()
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.
getAllFields in interface MessageOrBuildergetAllFields in class GeneratedMessageV3public java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFieldsRaw()
GeneratedMessageV3GeneratedMessageV3.getFieldRaw(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.public boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilderhasField in interface MessageOrBuilderhasField in class GeneratedMessageV3public java.lang.Object getField(Descriptors.FieldDescriptor field)
MessageOrBuildergetField in interface MessageOrBuildergetField in class GeneratedMessageV3public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuildergetRepeatedFieldCount in interface MessageOrBuildergetRepeatedFieldCount in class GeneratedMessageV3public java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
MessageOrBuildergetRepeatedField in interface MessageOrBuildergetRepeatedField in class GeneratedMessageV3