Class GeneratedMessageV3.ExtendableMessage<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
- java.lang.Object
-
- com.google.protobuf.AbstractMessageLite
-
- com.google.protobuf.AbstractMessage
-
- com.google.protobuf.GeneratedMessageV3
-
- com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageT>
-
- All Implemented Interfaces:
GeneratedMessageV3.ExtendableMessageOrBuilder<MessageT>
,Message
,MessageLite
,MessageLiteOrBuilder
,MessageOrBuilder
,java.io.Serializable
- Direct Known Subclasses:
DescriptorProtos.EnumOptions
,DescriptorProtos.EnumValueOptions
,DescriptorProtos.ExtensionRangeOptions
,DescriptorProtos.FieldOptions
,DescriptorProtos.FileOptions
,DescriptorProtos.MessageOptions
,DescriptorProtos.MethodOptions
,DescriptorProtos.OneofOptions
,DescriptorProtos.ServiceOptions
- Enclosing class:
- GeneratedMessageV3
public abstract static class GeneratedMessageV3.ExtendableMessage<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>> extends GeneratedMessageV3 implements GeneratedMessageV3.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
GeneratedMessageV3.ExtendableBuilder
.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
GeneratedMessageV3.ExtendableMessage.ExtensionWriter
Used by subclasses to serialize extensions.-
Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessageV3
GeneratedMessageV3.Builder<BuilderT extends GeneratedMessageV3.Builder<BuilderT>>, GeneratedMessageV3.BuilderParent, GeneratedMessageV3.ExtendableBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>,BuilderT extends GeneratedMessageV3.ExtendableBuilder<MessageT,BuilderT>>, GeneratedMessageV3.ExtendableMessage<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>, GeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>, GeneratedMessageV3.FieldAccessorTable, GeneratedMessageV3.UnusedPrivateParameter
-
Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite
AbstractMessageLite.InternalOneOfEnum
-
-
Field Summary
-
Fields inherited from class com.google.protobuf.GeneratedMessageV3
alwaysUseFieldBuilders, unknownFields
-
Fields inherited from class com.google.protobuf.AbstractMessage
memoizedSize
-
Fields inherited from class com.google.protobuf.AbstractMessageLite
memoizedHashCode
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ExtendableMessage()
protected
ExtendableMessage(GeneratedMessageV3.ExtendableBuilder<MessageT,?> builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
java.util.Map<Descriptors.FieldDescriptor,java.lang.Object>
getAllFields()
Returns a collection of all the fields in this message which are set and their corresponding values.java.util.Map<Descriptors.FieldDescriptor,java.lang.Object>
getAllFieldsRaw()
<T> T
getExtension(Extension<MessageT,java.util.List<T>> extension, int index)
Get one element of a repeated extension.<T> T
getExtension(Extension<MessageT,T> extension)
Get the value of an extension.<T> T
getExtension(ExtensionLite<MessageT,java.util.List<T>> extensionLite, int index)
Get one element of a repeated extension.<T> T
getExtension(ExtensionLite<MessageT,T> extensionLite)
Get the value of an extension.<T> T
getExtension(GeneratedMessage.GeneratedExtension<MessageT,java.util.List<T>> extension, int index)
Get one element of a repeated extension.<T> T
getExtension(GeneratedMessage.GeneratedExtension<MessageT,T> extension)
Get the value of an extension.<T> int
getExtensionCount(Extension<MessageT,java.util.List<T>> extension)
Get the number of elements in a repeated extension.<T> int
getExtensionCount(ExtensionLite<MessageT,java.util.List<T>> extensionLite)
Get the number of elements in a repeated extension.<T> int
getExtensionCount(GeneratedMessage.GeneratedExtension<MessageT,java.util.List<T>> extension)
Get the number of elements in a repeated extension.protected java.util.Map<Descriptors.FieldDescriptor,java.lang.Object>
getExtensionFields()
java.lang.Object
getField(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is not set.java.lang.Object
getRepeatedField(Descriptors.FieldDescriptor field, int index)
Gets an element of a repeated field.int
getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Gets the number of elements of a repeated field.<T> boolean
hasExtension(Extension<MessageT,T> extension)
Check if a singular extension is present.<T> boolean
hasExtension(ExtensionLite<MessageT,T> extensionLite)
Check if a singular extension is present.<T> boolean
hasExtension(GeneratedMessage.GeneratedExtension<MessageT,T> extension)
Check if a singular extension is present.boolean
hasField(Descriptors.FieldDescriptor field)
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 GeneratedMessageV3.ExtendableMessage.ExtensionWriter
newExtensionWriter()
protected GeneratedMessageV3.ExtendableMessage.ExtensionWriter
newMessageSetExtensionWriter()
protected boolean
parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)
Called by subclasses to parse an unknown field.protected boolean
parseUnknownFieldProto3(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)
Delegates to parseUnknownField.-
Methods inherited from class com.google.protobuf.GeneratedMessageV3
canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyLongList, getDescriptorForType, getOneofFieldDescriptor, getParserForType, getSerializedSize, getUnknownFields, hasOneof, internalGetFieldAccessorTable, internalGetMapField, isStringEmpty, makeMutableCopy, mergeFromAndMakeImmutableInternal, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBooleanList, newBuilderForType, newBuilderForType, newDoubleList, newFloatList, newInstance, newIntList, newLongList, parseDelimitedWithIOException, parseDelimitedWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTag, writeTo
-
Methods inherited from class com.google.protobuf.AbstractMessage
equals, findInitializationErrors, getInitializationErrorString, hashBoolean, hashCode, hashEnum, hashEnumList, hashFields, hashLong, toString
-
Methods inherited from class com.google.protobuf.AbstractMessageLite
addAll, addAll, checkByteStringIsUtf8, 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.GeneratedMessageV3.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
-
-
-
-
Constructor Detail
-
ExtendableMessage
protected ExtendableMessage()
-
ExtendableMessage
protected ExtendableMessage(GeneratedMessageV3.ExtendableBuilder<MessageT,?> builder)
-
-
Method Detail
-
hasExtension
public final <T> boolean hasExtension(ExtensionLite<MessageT,T> extensionLite)
Check if a singular extension is present.- Specified by:
hasExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtensionCount
public final <T> int getExtensionCount(ExtensionLite<MessageT,java.util.List<T>> extensionLite)
Get the number of elements in a repeated extension.- Specified by:
getExtensionCount
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtension
public final <T> T getExtension(ExtensionLite<MessageT,T> extensionLite)
Get the value of an extension.- Specified by:
getExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtension
public final <T> T getExtension(ExtensionLite<MessageT,java.util.List<T>> extensionLite, int index)
Get one element of a repeated extension.- Specified by:
getExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
hasExtension
public final <T> boolean hasExtension(Extension<MessageT,T> extension)
Check if a singular extension is present.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
hasExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
hasExtension
public final <T> boolean hasExtension(GeneratedMessage.GeneratedExtension<MessageT,T> extension)
Check if a singular extension is present.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
hasExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtensionCount
public final <T> int getExtensionCount(Extension<MessageT,java.util.List<T>> extension)
Get the number of elements in a repeated extension.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
getExtensionCount
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtensionCount
public final <T> int getExtensionCount(GeneratedMessage.GeneratedExtension<MessageT,java.util.List<T>> extension)
Get the number of elements in a repeated extension.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
getExtensionCount
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtension
public final <T> T getExtension(Extension<MessageT,T> extension)
Get the value of an extension.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
getExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtension
public final <T> T getExtension(GeneratedMessage.GeneratedExtension<MessageT,T> extension)
Get the value of an extension.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
getExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtension
public final <T> T getExtension(Extension<MessageT,java.util.List<T>> extension, int index)
Get one element of a repeated extension.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
getExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
getExtension
public final <T> T getExtension(GeneratedMessage.GeneratedExtension<MessageT,java.util.List<T>> extension, int index)
Get one element of a repeated extension.TODO(b/258340024): handled by ExtensionLite version
- Specified by:
getExtension
in interfaceGeneratedMessageV3.ExtendableMessageOrBuilder<MessageT extends GeneratedMessageV3.ExtendableMessage<MessageT>>
-
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 classGeneratedMessageV3
-
parseUnknownField
protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws java.io.IOException
Description copied from class:GeneratedMessageV3
Called by subclasses to parse an unknown field.TODO(b/248153893) remove this method
- Overrides:
parseUnknownField
in classGeneratedMessageV3
- Returns:
true
unless the tag is an end-group tag.- Throws:
java.io.IOException
-
parseUnknownFieldProto3
protected boolean parseUnknownFieldProto3(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws java.io.IOException
Delegates to parseUnknownField. This method is obsolete, but we must retain it for compatibility with older generated code.TODO(b/248153893): remove mutating method from immutable type
- Overrides:
parseUnknownFieldProto3
in classGeneratedMessageV3
- Throws:
java.io.IOException
-
makeExtensionsImmutable
protected void makeExtensionsImmutable()
Used by parsing constructors in generated classes.TODO(b/258340024): remove unused method (extensions should be immutable after build)
- Overrides:
makeExtensionsImmutable
in classGeneratedMessageV3
-
newExtensionWriter
protected GeneratedMessageV3.ExtendableMessage.ExtensionWriter newExtensionWriter()
-
newMessageSetExtensionWriter
protected GeneratedMessageV3.ExtendableMessage.ExtensionWriter newMessageSetExtensionWriter()
-
extensionsSerializedSize
protected int extensionsSerializedSize()
Called by subclasses to compute the size of extensions.
-
extensionsSerializedSizeAsMessageSet
protected int extensionsSerializedSizeAsMessageSet()
-
getExtensionFields
protected java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getExtensionFields()
-
getAllFields
public java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> 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 classGeneratedMessageV3
-
getAllFieldsRaw
public java.util.Map<Descriptors.FieldDescriptor,java.lang.Object> getAllFieldsRaw()
-
hasField
public boolean hasField(Descriptors.FieldDescriptor field)
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 classGeneratedMessageV3
-
getField
public java.lang.Object getField(Descriptors.FieldDescriptor field)
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 classGeneratedMessageV3
-
getRepeatedFieldCount
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
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 classGeneratedMessageV3
-
getRepeatedField
public java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
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 classGeneratedMessageV3
-
-