public abstract static class GeneratedMessage.ExtendableMessage<MessageType> extends GeneratedMessage implements GeneratedMessage.ExtendableMessageOrBuilder<MessageType>
Generated message classes for message types that contain extension ranges
subclass this.
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 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 ExtendableBuilder.
Implements
com.google.protobuf.GeneratedMessage.ExtendableMessageOrBuilder<MessageType>
Type Parameter |
---|
Name | Description |
MessageType | |
Constructors
ExtendableMessage()
protected ExtendableMessage()
ExtendableMessage(GeneratedMessage.ExtendableBuilder<MessageType,?> builder)
protected ExtendableMessage(GeneratedMessage.ExtendableBuilder<MessageType,?> builder)
Methods
<Type>getExtension(Extension<MessageType,Type> extension)
public final Type <Type>getExtension(Extension<MessageType,Type> extension)
Get the value of an extension.
Parameter |
---|
Name | Description |
extension | Extension<MessageType,Type>
|
Returns |
---|
Type | Description |
Type | |
<Type>getExtension(Extension<MessageType,List<Type>> extension, int index)
public final Type <Type>getExtension(Extension<MessageType,List<Type>> extension, int index)
Get one element of a repeated extension.
Returns |
---|
Type | Description |
Type | |
<Type>getExtension(ExtensionLite<MessageType,Type> extensionLite)
public final Type <Type>getExtension(ExtensionLite<MessageType,Type> extensionLite)
Get the value of an extension.
Parameter |
---|
Name | Description |
extensionLite | ExtensionLite<MessageType,Type>
|
Returns |
---|
Type | Description |
Type | |
<Type>getExtension(ExtensionLite<MessageType,List<Type>> extensionLite, int index)
public final Type <Type>getExtension(ExtensionLite<MessageType,List<Type>> extensionLite, int index)
Get one element of a repeated extension.
Returns |
---|
Type | Description |
Type | |
<Type>getExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
public final Type <Type>getExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
Get the value of an extension.
Returns |
---|
Type | Description |
Type | |
<Type>getExtension(GeneratedMessage.GeneratedExtension<MessageType,List<Type>> extension, int index)
public final Type <Type>getExtension(GeneratedMessage.GeneratedExtension<MessageType,List<Type>> extension, int index)
Get one element of a repeated extension.
Returns |
---|
Type | Description |
Type | |
<Type>getExtensionCount(Extension<MessageType,List<Type>> extension)
public final int <Type>getExtensionCount(Extension<MessageType,List<Type>> extension)
Get the number of elements in a repeated extension.
Parameter |
---|
Name | Description |
extension | Extension<MessageType,List<Type>>
|
Returns |
---|
Type | Description |
int | |
<Type>getExtensionCount(ExtensionLite<MessageType,List<Type>> extensionLite)
public final int <Type>getExtensionCount(ExtensionLite<MessageType,List<Type>> extensionLite)
Get the number of elements in a repeated extension.
Returns |
---|
Type | Description |
int | |
<Type>getExtensionCount(GeneratedMessage.GeneratedExtension<MessageType,List<Type>> extension)
public final int <Type>getExtensionCount(GeneratedMessage.GeneratedExtension<MessageType,List<Type>> extension)
Get the number of elements in a repeated extension.
Returns |
---|
Type | Description |
int | |
<Type>hasExtension(Extension<MessageType,Type> extension)
public final boolean <Type>hasExtension(Extension<MessageType,Type> extension)
Check if a singular extension is present.
Parameter |
---|
Name | Description |
extension | Extension<MessageType,Type>
|
<Type>hasExtension(ExtensionLite<MessageType,Type> extensionLite)
public final boolean <Type>hasExtension(ExtensionLite<MessageType,Type> extensionLite)
Check if a singular extension is present.
Parameter |
---|
Name | Description |
extensionLite | ExtensionLite<MessageType,Type>
|
<Type>hasExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
public final boolean <Type>hasExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)
Check if a singular extension is present.
extensionsAreInitialized()
protected boolean extensionsAreInitialized()
Called by subclasses to check if all extensions are initialized.
extensionsSerializedSize()
protected int extensionsSerializedSize()
Called by subclasses to compute the size of extensions.
Returns |
---|
Type | Description |
int | |
extensionsSerializedSizeAsMessageSet()
protected int extensionsSerializedSizeAsMessageSet()
Returns |
---|
Type | Description |
int | |
getAllFields()
public Map<Descriptors.FieldDescriptor,Object> getAllFields()
Returns a collection of all the fields in this message which are set and their corresponding
values. A singular ("required" or "optional") field is set iff hasField() returns true for that
field. A "repeated" field is set iff getRepeatedFieldCount() is greater than zero. The values
are exactly what would be returned by calling #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.
If this is for a builder, the returned map may or may not reflect future changes to the
builder. Either way, the returned map is itself unmodifiable.
Overrides
getAllFieldsRaw()
public Map<Descriptors.FieldDescriptor,Object> getAllFieldsRaw()
getExtensionFields()
protected Map<Descriptors.FieldDescriptor,Object> getExtensionFields()
getField(Descriptors.FieldDescriptor field)
public Object getField(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is not set. For primitive
fields, the boxed primitive value is returned. For enum fields, the EnumValueDescriptor for the
value is returned. For embedded message fields, the sub-message is returned. For repeated
fields, a java.util.List is returned.
Overrides
getRepeatedField(Descriptors.FieldDescriptor field, int index)
public Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
Gets an element of a repeated field. For primitive fields, the boxed primitive value is
returned. For enum fields, the EnumValueDescriptor for the value is returned. For embedded
message fields, the sub-message is returned.
Overrides
getRepeatedFieldCount(Descriptors.FieldDescriptor field)
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Gets the number of elements of a repeated field. This is exactly equivalent to calling the
generated "Count" accessor method corresponding to the field.
Returns |
---|
Type | Description |
int | |
Overrides
hasField(Descriptors.FieldDescriptor field)
public boolean hasField(Descriptors.FieldDescriptor field)
Returns true if the given field is set. This is exactly equivalent to calling the generated
"has" accessor method corresponding to the field.
Overrides
isInitialized()
public boolean isInitialized()
Overrides
makeExtensionsImmutable()
protected void makeExtensionsImmutable()
Used by parsing constructors in generated classes.
Overrides
newExtensionWriter()
protected GeneratedMessage.ExtendableMessage<MessageType>.ExtensionWriter newExtensionWriter()
newMessageSetExtensionWriter()
protected GeneratedMessage.ExtendableMessage<MessageType>.ExtensionWriter newMessageSetExtensionWriter()
protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)
Called by subclasses to parse an unknown field.
Overrides