public abstract static class GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage extends GeneratedMessage> implements GeneratedMessage .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 GeneratedMessage.ExtendableBuilder.
| Modifier and Type | Class and Description |
|---|---|
protected class |
GeneratedMessage
Used by subclasses to serialize extensions.
|
GeneratedMessage.Builder <BuilderType extends GeneratedMessage.Builder >, GeneratedMessage.BuilderParent , GeneratedMessage.ExtendableBuilder <MessageType extends GeneratedMessage.ExtendableMessage ,BuilderType extends GeneratedMessage.ExtendableBuilder >, GeneratedMessage.ExtendableMessage <MessageType extends GeneratedMessage.ExtendableMessage >, GeneratedMessage.ExtendableMessageOrBuilder <MessageType extends GeneratedMessage.ExtendableMessage >, GeneratedMessage.FieldAccessorTable , GeneratedMessage.GeneratedExtension <ContainingType extends Message,Type> alwaysUseFieldBuildersmemoizedHashCode| Modifier | Constructor and Description |
|---|---|
protected |
ExtendableMessage()
|
protected |
ExtendableMessage(GeneratedMessage
|
| 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()
|
Map |
getAllFields()
Returns a collection of all the fields in this message which are set and their corresponding values.
|
<Type> Type |
getExtension(Extension
Get one element of a repeated extension.
|
<Type> Type |
getExtension(Extension
Get the value of an extension.
|
<Type> int |
getExtensionCount(Extension
Get the number of elements in a repeated extension.
|
protected Map |
getExtensionFields()
|
Object |
getField(Descriptors
Obtains the value of the given field, or the default value if it is not set.
|
Object |
getRepeatedField(Descriptors
Gets an element of a repeated field.
|
int |
getRepeatedFieldCount(Descriptors
Gets the number of elements of a repeated field.
|
<Type> boolean |
hasExtension(Extension
Check if a singular extension is present.
|
boolean |
hasField(Descriptors
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 GeneratedMessage |
newExtensionWriter()
|
protected GeneratedMessage |
newMessageSetExtensionWriter()
|
protected boolean |
parseUnknownField(CodedInputStream
Called by subclasses to parse an unknown field.
|
getDescriptorForType, getOneofFieldDescriptor, getParserForType, getUnknownFields, hasOneof, internalGetFieldAccessorTable, newBuilderForType, newFileScopedGeneratedExtension, newFileScopedGeneratedExtension, newMessageScopedGeneratedExtension, newMessageScopedGeneratedExtension, writeReplaceequals, findInitializationErrors, getInitializationErrorString, getSerializedSize, hashCode, hashFields, toString, writeTocheckByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeToclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetDefaultInstanceForTypefindInitializationErrors, getDescriptorForType, getInitializationErrorString, getOneofFieldDescriptor, getUnknownFields, hasOneofnewBuilderForType, toBuildertoByteArray, toByteString, writeDelimitedTo, writeToprotected ExtendableMessage()
protected ExtendableMessage(GeneratedMessage.ExtendableBuilder <MessageType ,?> builder)
public final <Type> boolean hasExtension(Extension<MessageType ,Type> extension)
public final <Type> int getExtensionCount(Extension<MessageType ,List <Type>> extension)
public final <Type> Type getExtension(Extension<MessageType ,Type> extension)
public final <Type> Type getExtension(Extension<MessageType ,List <Type>> extension, int index)
protected boolean extensionsAreInitialized()
public boolean isInitialized()
MessageLiteOrBuilder
protected boolean parseUnknownField(CodedInputStreaminput, UnknownFieldSet .Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws IOException
GeneratedMessage
parseUnknownField in class
GeneratedMessage
true unless the tag is an end-group tag.
IOException
protected void makeExtensionsImmutable()
protected GeneratedMessage.ExtendableMessage .ExtensionWriter newExtensionWriter()
protected GeneratedMessage.ExtendableMessage .ExtensionWriter newMessageSetExtensionWriter()
protected int extensionsSerializedSize()
protected int extensionsSerializedSizeAsMessageSet()
protected Map<Descriptors .FieldDescriptor ,Object > getExtensionFields()
public Map<Descriptors .FieldDescriptor ,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.
public boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public ObjectgetField(Descriptors .FieldDescriptor field)
MessageOrBuilder
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuilder
public ObjectgetRepeatedField(Descriptors .FieldDescriptor field, int index)
MessageOrBuilder