Class GeneratedMessageV3.ExtendableMessage<MessageType> (3.19.4)

public abstract static class GeneratedMessageV3.ExtendableMessage<MessageType> extends GeneratedMessageV3 implements GeneratedMessageV3.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.

Inheritance

Object > AbstractMessageLite<MessageType,BuilderType> > AbstractMessage > GeneratedMessageV3 > GeneratedMessageV3.ExtendableMessage<MessageType>

Implements

com.google.protobuf.GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType>

Type Parameter

NameDescription
MessageType

Constructors

ExtendableMessage()

protected ExtendableMessage()

ExtendableMessage(GeneratedMessageV3.ExtendableBuilder<MessageType,?> builder)

protected ExtendableMessage(GeneratedMessageV3.ExtendableBuilder<MessageType,?> builder)
Parameter
NameDescription
builderExtendableBuilder<MessageType,?>

Methods

<Type>getExtension(Extension<MessageType,Type> extension)

public final Type <Type>getExtension(Extension<MessageType,Type> extension)

Get the value of an extension.

Parameter
NameDescription
extensionExtension<MessageType,Type>
Returns
TypeDescription
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.

Parameters
NameDescription
extensionExtension<MessageType,List<Type>>
indexint
Returns
TypeDescription
Type

<Type>getExtension(ExtensionLite<MessageType,Type> extensionLite)

public final Type <Type>getExtension(ExtensionLite<MessageType,Type> extensionLite)

Get the value of an extension.

Parameter
NameDescription
extensionLiteExtensionLite<MessageType,Type>
Returns
TypeDescription
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.

Parameters
NameDescription
extensionLiteExtensionLite<MessageType,List<Type>>
indexint
Returns
TypeDescription
Type

<Type>getExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)

public final Type <Type>getExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)

Get the value of an extension.

Parameter
NameDescription
extensionGeneratedExtension<MessageType,Type>
Returns
TypeDescription
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.

Parameters
NameDescription
extensionGeneratedExtension<MessageType,List<Type>>
indexint
Returns
TypeDescription
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
NameDescription
extensionExtension<MessageType,List<Type>>
Returns
TypeDescription
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.

Parameter
NameDescription
extensionLiteExtensionLite<MessageType,List<Type>>
Returns
TypeDescription
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.

Parameter
NameDescription
extensionGeneratedExtension<MessageType,List<Type>>
Returns
TypeDescription
int

<Type>hasExtension(Extension<MessageType,Type> extension)

public final boolean <Type>hasExtension(Extension<MessageType,Type> extension)

Check if a singular extension is present.

Parameter
NameDescription
extensionExtension<MessageType,Type>
Returns
TypeDescription
boolean

<Type>hasExtension(ExtensionLite<MessageType,Type> extensionLite)

public final boolean <Type>hasExtension(ExtensionLite<MessageType,Type> extensionLite)

Check if a singular extension is present.

Parameter
NameDescription
extensionLiteExtensionLite<MessageType,Type>
Returns
TypeDescription
boolean

<Type>hasExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)

public final boolean <Type>hasExtension(GeneratedMessage.GeneratedExtension<MessageType,Type> extension)

Check if a singular extension is present.

Parameter
NameDescription
extensionGeneratedExtension<MessageType,Type>
Returns
TypeDescription
boolean

extensionsAreInitialized()

protected boolean extensionsAreInitialized()

Called by subclasses to check if all extensions are initialized.

Returns
TypeDescription
boolean

extensionsSerializedSize()

protected int extensionsSerializedSize()

Called by subclasses to compute the size of extensions.

Returns
TypeDescription
int

extensionsSerializedSizeAsMessageSet()

protected int extensionsSerializedSizeAsMessageSet()
Returns
TypeDescription
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.

Returns
TypeDescription
Map<FieldDescriptor,Object>
Overrides

getAllFieldsRaw()

public Map<Descriptors.FieldDescriptor,Object> getAllFieldsRaw()
Returns
TypeDescription
Map<FieldDescriptor,Object>

getExtensionFields()

protected Map<Descriptors.FieldDescriptor,Object> getExtensionFields()
Returns
TypeDescription
Map<FieldDescriptor,Object>

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.

Parameter
NameDescription
fieldDescriptors.FieldDescriptor
Returns
TypeDescription
Object
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.

Parameters
NameDescription
fieldDescriptors.FieldDescriptor
indexint
Returns
TypeDescription
Object
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.

Parameter
NameDescription
fieldDescriptors.FieldDescriptor
Returns
TypeDescription
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.

Parameter
NameDescription
fieldDescriptors.FieldDescriptor
Returns
TypeDescription
boolean
Overrides

isInitialized()

public boolean isInitialized()

Returns true if all required fields in the message and all embedded messages are set, false otherwise.

See also: MessageOrBuilder#getInitializationErrorString()

Returns
TypeDescription
boolean
Overrides

makeExtensionsImmutable()

protected void makeExtensionsImmutable()

Used by parsing constructors in generated classes.

Overrides

newExtensionWriter()

protected GeneratedMessageV3.ExtendableMessage<MessageType>.ExtensionWriter newExtensionWriter()
Returns
TypeDescription
ExtendableMessage<MessageType>.ExtensionWriter

newMessageSetExtensionWriter()

protected GeneratedMessageV3.ExtendableMessage<MessageType>.ExtensionWriter newMessageSetExtensionWriter()
Returns
TypeDescription
ExtendableMessage<MessageType>.ExtensionWriter

parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)

protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)

Called by subclasses to parse an unknown field.

Parameters
NameDescription
inputCodedInputStream
unknownFieldsUnknownFieldSet.Builder
extensionRegistryExtensionRegistryLite
tagint
Returns
TypeDescription
boolean
Overrides
Exceptions
TypeDescription
IOException

parseUnknownFieldProto3(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)

protected boolean parseUnknownFieldProto3(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)

Delegates to parseUnknownField. This method is obsolete, but we must retain it for compatibility with older generated code.

Parameters
NameDescription
inputCodedInputStream
unknownFieldsUnknownFieldSet.Builder
extensionRegistryExtensionRegistryLite
tagint
Returns
TypeDescription
boolean
Overrides
Exceptions
TypeDescription
IOException