Package com.google.protobuf
Class GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage>
java.lang.Object
com.google.protobuf.AbstractMessageLite
com.google.protobuf.AbstractMessage
com.google.protobuf.GeneratedMessage
com.google.protobuf.GeneratedMessage.ExtendableMessage<MessageType>
- All Implemented Interfaces:
GeneratedMessage.ExtendableMessageOrBuilder<MessageType>
,Message
,MessageLite
,MessageLiteOrBuilder
,MessageOrBuilder
,Serializable
- Enclosing class:
GeneratedMessage
public abstract static class GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage>
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 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
.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected class
Used by subclasses to serialize extensions.Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessage
GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder<BuilderType>>, GeneratedMessage.BuilderParent, GeneratedMessage.ExtendableBuilder<MessageType extends GeneratedMessage.ExtendableMessage,
BuilderType extends GeneratedMessage.ExtendableBuilder<MessageType, BuilderType>>, GeneratedMessage.ExtendableMessage<MessageType extends GeneratedMessage.ExtendableMessage>, GeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>, GeneratedMessage.ExtensionDescriptorRetriever, GeneratedMessage.FieldAccessorTable, GeneratedMessage.GeneratedExtension<ContainingType extends Message, Type> Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite
AbstractMessageLite.InternalOneOfEnum
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FieldSet
<Descriptors.FieldDescriptor> private static final long
Fields inherited from class com.google.protobuf.GeneratedMessage
alwaysUseFieldBuilders, unknownFields
Fields inherited from class com.google.protobuf.AbstractMessage
memoizedSize
Fields inherited from class com.google.protobuf.AbstractMessageLite
memoizedHashCode
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
protected
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Called by subclasses to check if all extensions are initialized.protected int
Called by subclasses to compute the size of extensions.protected int
Returns a collection of all the fields in this message which are set and their corresponding values.Returns a collection of all the fields in this message which are set and their corresponding values.final <Type> Type
getExtension
(Extension<MessageType, List<Type>> extension, int index) Get one element of a repeated extension.final <Type> Type
getExtension
(Extension<MessageType, Type> extension) Get the value of an extension.final <Type> Type
getExtension
(ExtensionLite<MessageType, List<Type>> extensionLite, int index) Get one element of a repeated extension.final <Type> Type
getExtension
(ExtensionLite<MessageType, Type> extensionLite) Get the value of an extension.final <Type> Type
getExtension
(GeneratedMessage.GeneratedExtension<MessageType, List<Type>> extension, int index) Get one element of a repeated extension.final <Type> Type
getExtension
(GeneratedMessage.GeneratedExtension<MessageType, Type> extension) Get the value of an extension.final <Type> int
getExtensionCount
(Extension<MessageType, List<Type>> extension) Get the number of elements in a repeated extension.final <Type> int
getExtensionCount
(ExtensionLite<MessageType, List<Type>> extensionLite) Get the number of elements in a repeated extension.final <Type> int
getExtensionCount
(GeneratedMessage.GeneratedExtension<MessageType, List<Type>> extension) Get the number of elements in a repeated extension.protected Map
<Descriptors.FieldDescriptor, Object> Obtains the value of the given field, or the default value if it is not set.getRepeatedField
(Descriptors.FieldDescriptor field, int index) Gets an element of a repeated field.int
Gets the number of elements of a repeated field.final <Type> boolean
hasExtension
(Extension<MessageType, Type> extension) Check if a singular extension is present.final <Type> boolean
hasExtension
(ExtensionLite<MessageType, Type> extensionLite) Check if a singular extension is present.final <Type> boolean
hasExtension
(GeneratedMessage.GeneratedExtension<MessageType, Type> extension) Check if a singular extension is present.boolean
Returns true if the given field is set.boolean
Returns true if all required fields in the message and all embedded messages are set, false otherwise.protected void
Used by parsing constructors in generated classes.protected boolean
parseUnknownField
(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) Called by subclasses to parse an unknown field.private void
private void
verifyExtensionContainingType
(Extension<MessageType, ?> extension) Methods inherited from class com.google.protobuf.GeneratedMessage
computeStringSize, computeStringSizeNoTag, enableAlwaysUseFieldBuildersForTesting, getDescriptorForType, getFieldRaw, getOneofFieldDescriptor, getParserForType, getSerializedSize, getUnknownFields, hasOneof, internalGetFieldAccessorTable, internalGetMapField, newBuilderForType, newBuilderForType, newFileScopedGeneratedExtension, newFileScopedGeneratedExtension, newMessageScopedGeneratedExtension, newMessageScopedGeneratedExtension, parseDelimitedWithIOException, parseDelimitedWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, writeReplace, writeString, writeStringNoTag, writeTo
Methods inherited from class com.google.protobuf.AbstractMessage
compareFields, equals, findInitializationErrors, getInitializationErrorString, getMemoizedSerializedSize, hashBoolean, hashCode, hashEnum, hashEnumList, hashFields, hashLong, newUninitializedMessageException, setMemoizedSerializedSize, toString
Methods inherited from class com.google.protobuf.AbstractMessageLite
addAll, addAll, checkByteStringIsUtf8, getSerializedSize, toByteArray, toByteString, writeDelimitedTo, writeTo
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.protobuf.GeneratedMessage.ExtendableMessageOrBuilder
getDefaultInstanceForType
Methods inherited from interface com.google.protobuf.Message
newBuilderForType, toBuilder
Methods inherited from interface com.google.protobuf.MessageLite
toByteArray, toByteString, writeDelimitedTo, writeTo
Methods inherited from interface com.google.protobuf.MessageOrBuilder
findInitializationErrors, getDescriptorForType, getInitializationErrorString, getOneofFieldDescriptor, getUnknownFields, hasOneof
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
extensions
-
-
Constructor Details
-
ExtendableMessage
protected ExtendableMessage() -
ExtendableMessage
-
-
Method Details
-
verifyExtensionContainingType
-
hasExtension
Check if a singular extension is present.- Specified by:
hasExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtensionCount
Get the number of elements in a repeated extension.- Specified by:
getExtensionCount
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtension
Get the value of an extension.- Specified by:
getExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtension
public final <Type> Type getExtension(ExtensionLite<MessageType, List<Type>> extensionLite, int index) Get one element of a repeated extension.- Specified by:
getExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
hasExtension
Check if a singular extension is present.- Specified by:
hasExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
hasExtension
public final <Type> boolean hasExtension(GeneratedMessage.GeneratedExtension<MessageType, Type> extension) Check if a singular extension is present.- Specified by:
hasExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtensionCount
Get the number of elements in a repeated extension.- Specified by:
getExtensionCount
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtensionCount
public final <Type> int getExtensionCount(GeneratedMessage.GeneratedExtension<MessageType, List<Type>> extension) Get the number of elements in a repeated extension.- Specified by:
getExtensionCount
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtension
Get the value of an extension.- Specified by:
getExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtension
public final <Type> Type getExtension(GeneratedMessage.GeneratedExtension<MessageType, Type> extension) Get the value of an extension.- Specified by:
getExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtension
Get one element of a repeated extension.- Specified by:
getExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
getExtension
public final <Type> Type getExtension(GeneratedMessage.GeneratedExtension<MessageType, List<Type>> extension, int index) Get one element of a repeated extension.- Specified by:
getExtension
in interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageType extends GeneratedMessage.ExtendableMessage>
-
extensionsAreInitialized
protected boolean extensionsAreInitialized()Called by subclasses to check if all extensions are initialized. -
isInitialized
public boolean isInitialized()Description copied from interface:MessageLiteOrBuilder
Returns true if all required fields in the message and all embedded messages are set, false otherwise.- Specified by:
isInitialized
in interfaceMessageLiteOrBuilder
- Overrides:
isInitialized
in classGeneratedMessage
-
parseUnknownField
protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws IOException Description copied from class:GeneratedMessage
Called by subclasses to parse an unknown field.- Overrides:
parseUnknownField
in classGeneratedMessage
- Returns:
true
unless the tag is an end-group tag.- Throws:
IOException
-
makeExtensionsImmutable
protected void makeExtensionsImmutable()Used by parsing constructors in generated classes.- Overrides:
makeExtensionsImmutable
in classGeneratedMessage
-
newExtensionWriter
-
newMessageSetExtensionWriter
protected GeneratedMessage.ExtendableMessage<MessageType>.ExtensionWriter newMessageSetExtensionWriter() -
extensionsSerializedSize
protected int extensionsSerializedSize()Called by subclasses to compute the size of extensions. -
extensionsSerializedSizeAsMessageSet
protected int extensionsSerializedSizeAsMessageSet() -
getExtensionFields
-
getAllFields
Description copied from interface:MessageOrBuilder
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 callingMessageOrBuilder.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.- Specified by:
getAllFields
in interfaceMessageOrBuilder
- Overrides:
getAllFields
in classGeneratedMessage
-
getAllFieldsRaw
Description copied from class:GeneratedMessage
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 callingGeneratedMessage.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.- Overrides:
getAllFieldsRaw
in classGeneratedMessage
-
hasField
Description copied from interface:MessageOrBuilder
Returns true if the given field is set. This is exactly equivalent to calling the generated "has" accessor method corresponding to the field.- Specified by:
hasField
in interfaceMessageOrBuilder
- Overrides:
hasField
in classGeneratedMessage
-
getField
Description copied from interface:MessageOrBuilder
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.- Specified by:
getField
in interfaceMessageOrBuilder
- Overrides:
getField
in classGeneratedMessage
-
getRepeatedFieldCount
Description copied from interface:MessageOrBuilder
Gets the number of elements of a repeated field. This is exactly equivalent to calling the generated "Count" accessor method corresponding to the field.- Specified by:
getRepeatedFieldCount
in interfaceMessageOrBuilder
- Overrides:
getRepeatedFieldCount
in classGeneratedMessage
-
getRepeatedField
Description copied from interface:MessageOrBuilder
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.- Specified by:
getRepeatedField
in interfaceMessageOrBuilder
- Overrides:
getRepeatedField
in classGeneratedMessage
-
verifyContainingType
-