Class GeneratedMessage.ExtendableMessage<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>
java.lang.Object
com.google.protobuf.AbstractMessageLite
com.google.protobuf.AbstractMessage
com.google.protobuf.GeneratedMessage
com.google.protobuf.GeneratedMessage.ExtendableMessage<MessageT>
- All Implemented Interfaces:
GeneratedMessage.ExtendableMessageOrBuilder<MessageT>, Message, MessageLite, MessageLiteOrBuilder, MessageOrBuilder, Serializable
- Direct Known Subclasses:
GeneratedMessageV3
- Enclosing class:
GeneratedMessage
public abstract static class GeneratedMessage.ExtendableMessage<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>
extends GeneratedMessage
implements GeneratedMessage.ExtendableMessageOrBuilder<MessageT>
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 static interfaceUsed by subclasses to serialize extensions.protected classExtensionSerializer that writes extensions from the FieldSet, for messages with extensions.static final classA wrapper for a field descriptor and its value.private static final classprivate static final classNo-op implementation that writes nothing, for messages with no extensions.Nested classes/interfaces inherited from class GeneratedMessage
GeneratedMessage.Builder<BuilderT>, GeneratedMessage.ExtendableBuilder<MessageT,BuilderT>, GeneratedMessage.ExtendableMessage<MessageT>, GeneratedMessage.ExtendableMessageOrBuilder<MessageT>, GeneratedMessage.ExtensionDescriptorRetriever, GeneratedMessage.FieldAccessorTable, GeneratedMessage.GeneratedExtension<ContainingT, T>, GeneratedMessage.UnusedPrivateParameter Nested classes/interfaces inherited from class AbstractMessage
AbstractMessage.BuilderParentNested classes/interfaces inherited from class AbstractMessageLite
AbstractMessageLite.InternalOneOfEnum -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FieldSet<Descriptors.FieldDescriptor> private static final longFields inherited from class GeneratedMessage
alwaysUseFieldBuilders, loggedPre22TypeNames, PRE22_GENCODE_ERROR_PROPERTY, PRE22_GENCODE_SILENCE_PROPERTY, PRE22_GENCODE_VULNERABILITY_MESSAGE, unknownFieldsFields inherited from class AbstractMessage
memoizedSizeFields inherited from class AbstractMessageLite
memoizedHashCode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotected -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanCalled by subclasses to check if all extensions are initialized.Returns an iterator over the set extensions lazily wrapped inGeneratedMessage.ExtendableMessage.FieldEntryobjects.protected intCalled by subclasses to compute the size of extensions.protected intReturns 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 <T> TgetExtension(ExtensionLite<? extends MessageT, List<T>> extensionLite, int index) Get one element of a repeated extension.final <T> TgetExtension(ExtensionLite<? extends MessageT, T> extensionLite) Get the value of an extension.final <T> intgetExtensionCount(ExtensionLite<? extends MessageT, List<T>> extensionLite) 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.intGets the number of elements of a repeated field.final <T> booleanhasExtension(ExtensionLite<? extends MessageT, T> extensionLite) Check if a singular extension is present.booleanReturns true if the given field is set.booleanReturns true if all required fields in the message and all embedded messages are set, false otherwise.protected voidThis method only exists as a shim for pre-22 gencode (see.invalid reference
GeneratedMessage.warnPre22GencodeDeprecated.private voidprivate voidMethods inherited from class GeneratedMessage
canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyList, emptyLongList, enableAlwaysUseFieldBuildersForTesting, getDescriptorForType, getFieldRaw, getOneofFieldDescriptor, getParserForType, getSerializedSize, getUnknownFields, hasOneof, internalGetFieldAccessorTable, internalGetMapField, internalGetMapFieldReflection, isStringEmpty, makeMutableCopy, makeMutableCopy, mergeFromAndMakeImmutableInternal, newFileScopedGeneratedExtension, newInstance, newMessageScopedGeneratedExtension, parseDelimitedWithIOException, parseDelimitedWithIOException, parseUnknownField, parseUnknownFieldProto3, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, setAlwaysUseFieldBuildersForTesting, setUnknownFields, warnPre22Gencode, writeReplace, writeString, writeStringNoTag, writeToMethods inherited from class AbstractMessage
compareFields, equals, findInitializationErrors, getInitializationErrorString, getMemoizedSerializedSize, hashCode, hashFields, newBuilderForType, newUninitializedMessageException, setMemoizedSerializedSize, toStringMethods inherited from class AbstractMessageLite
addAll, checkByteStringIsUtf8, getSerializedSize, toByteArray, toByteString, writeDelimitedTo, writeToMethods inherited from interface GeneratedMessage.ExtendableMessageOrBuilder
getDefaultInstanceForType, getExtension, getExtension, getExtension, getExtension, getExtensionCount, getExtensionCount, hasExtension, hasExtensionMethods inherited from interface Message
newBuilderForType, toBuilderMethods inherited from interface MessageLite
toByteArray, toByteString, writeDelimitedTo, writeToMethods inherited from interface 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
-
extensionsIterator
Returns an iterator over the set extensions lazily wrapped inGeneratedMessage.ExtendableMessage.FieldEntryobjects. Order is unspecified. -
verifyExtensionContainingType
-
hasExtension
Check if a singular extension is present.- Specified by:
hasExtensionin interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>
-
getExtensionCount
Get the number of elements in a repeated extension.- Specified by:
getExtensionCountin interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>
-
getExtension
Get the value of an extension.- Specified by:
getExtensionin interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>
-
getExtension
public final <T> T getExtension(ExtensionLite<? extends MessageT, List<T>> extensionLite, int index) Get one element of a repeated extension.- Specified by:
getExtensionin interfaceGeneratedMessage.ExtendableMessageOrBuilder<MessageT extends GeneratedMessage.ExtendableMessage<MessageT>>
-
extensionsAreInitialized
protected boolean extensionsAreInitialized()Called by subclasses to check if all extensions are initialized. -
isInitialized
public boolean isInitialized()Description copied from interface:MessageLiteOrBuilderReturns true if all required fields in the message and all embedded messages are set, false otherwise.- Specified by:
isInitializedin interfaceMessageLiteOrBuilder- Overrides:
isInitializedin classGeneratedMessage
-
makeExtensionsImmutable
protected void makeExtensionsImmutable()This method only exists as a shim for pre-22 gencode (see.invalid reference
GeneratedMessage.warnPre22Gencode- Overrides:
makeExtensionsImmutablein classGeneratedMessage
-
newExtensionWriter
@Deprecated protected GeneratedMessage.ExtendableMessage<MessageT>.ExtensionWriter newExtensionWriter()Deprecated.UsenewExtensionSerializer()instead.For compatibility with older gencode.TODO Remove this in the next breaking release.
-
newExtensionSerializer
-
newMessageSetExtensionWriter
protected GeneratedMessage.ExtendableMessage<MessageT>.ExtensionWriter newMessageSetExtensionWriter() -
newMessageSetExtensionSerializer
-
extensionsSerializedSize
protected int extensionsSerializedSize()Called by subclasses to compute the size of extensions. -
extensionsSerializedSizeAsMessageSet
protected int extensionsSerializedSizeAsMessageSet() -
getExtensionFields
-
getAllFields
Description copied from interface:MessageOrBuilderReturns 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:
getAllFieldsin interfaceMessageOrBuilder- Overrides:
getAllFieldsin classGeneratedMessage
-
getAllFieldsRaw
Description copied from class:GeneratedMessageReturns 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:
getAllFieldsRawin classGeneratedMessage
-
hasField
Description copied from interface:MessageOrBuilderReturns true if the given field is set. This is exactly equivalent to calling the generated "has" accessor method corresponding to the field. The return value of hasField() is semantically meaningful only for fields where field.hasPresence() == true.- Specified by:
hasFieldin interfaceMessageOrBuilder- Overrides:
hasFieldin classGeneratedMessage
-
getField
Description copied from interface:MessageOrBuilderObtains 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:
getFieldin interfaceMessageOrBuilder- Overrides:
getFieldin classGeneratedMessage
-
getRepeatedFieldCount
Description copied from interface:MessageOrBuilderGets 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:
getRepeatedFieldCountin interfaceMessageOrBuilder- Overrides:
getRepeatedFieldCountin classGeneratedMessage
-
getRepeatedField
Description copied from interface:MessageOrBuilderGets 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:
getRepeatedFieldin interfaceMessageOrBuilder- Overrides:
getRepeatedFieldin classGeneratedMessage
-
verifyContainingType
-
newExtensionSerializer()instead.