Package com.google.protobuf
Class MessageReflection.ExtensionAdapter
java.lang.Object
com.google.protobuf.MessageReflection.ExtensionAdapter
- All Implemented Interfaces:
MessageReflection.MergeTarget
- Enclosing class:
MessageReflection
static class MessageReflection.ExtensionAdapter
extends Object
implements MessageReflection.MergeTarget
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.protobuf.MessageReflection.MergeTarget
MessageReflection.MergeTarget.ContainerType
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddRepeatedField
(Descriptors.FieldDescriptor field, Object value) LikesetRepeatedField
, but appends the value as a new element.Clears the field.Clears the oneof.findExtensionByName
(ExtensionRegistry registry, String name) findExtensionByNumber
(ExtensionRegistry registry, Descriptors.Descriptor containingType, int fieldNumber) finish()
Finishes the merge and returns the underlying object.Returns the descriptor for the target.Obtains the value of the given field, or the default value if it is not set.Obtains the FieldDescriptor if the given oneof is set.getUtf8Validation
(Descriptors.FieldDescriptor descriptor) Returns the UTF8 validation level for the field.boolean
Returns true if the given field is set.boolean
Returns true if the given oneof is set.void
mergeGroup
(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) Read the given group field from the wire, merging with the existing field if it is already present.void
mergeMessage
(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) Read the given message field from the wire, merging with the existing field if it is already present.newEmptyTargetForField
(Descriptors.FieldDescriptor descriptor, Message defaultInstance) Returns an empty merge target for a sub-field.newMergeTargetForField
(Descriptors.FieldDescriptor descriptor, Message defaultInstance) Returns a new merge target for a sub-field.parseGroup
(CodedInputStream input, ExtensionRegistryLite registry, Descriptors.FieldDescriptor field, Message defaultInstance) Parse the input stream into a sub field group defined based on either FieldDescriptor or the default instance.parseMessage
(CodedInputStream input, ExtensionRegistryLite registry, Descriptors.FieldDescriptor field, Message defaultInstance) Parse the input stream into a sub field message defined based on either FieldDescriptor or the default instance.parseMessageFromBytes
(ByteString bytes, ExtensionRegistryLite registry, Descriptors.FieldDescriptor field, Message defaultInstance) Parse from a ByteString into a sub field message defined based on either FieldDescriptor or the default instance.setField
(Descriptors.FieldDescriptor field, Object value) Sets a field to the given value.setRepeatedField
(Descriptors.FieldDescriptor field, int index, Object value) Sets an element of a repeated field to the given value.
-
Field Details
-
extensions
-
-
Constructor Details
-
ExtensionAdapter
ExtensionAdapter(FieldSet<Descriptors.FieldDescriptor> extensions)
-
-
Method Details
-
getDescriptorForType
Description copied from interface:MessageReflection.MergeTarget
Returns the descriptor for the target.- Specified by:
getDescriptorForType
in interfaceMessageReflection.MergeTarget
-
getField
Description copied from interface:MessageReflection.MergeTarget
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 interfaceMessageReflection.MergeTarget
-
hasField
Description copied from interface:MessageReflection.MergeTarget
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 interfaceMessageReflection.MergeTarget
-
setField
Description copied from interface:MessageReflection.MergeTarget
Sets a field to the given value. The value must be of the correct type for this field, i.e. the same type thatMessageOrBuilder.getField(Descriptors.FieldDescriptor)
would return.- Specified by:
setField
in interfaceMessageReflection.MergeTarget
-
clearField
Description copied from interface:MessageReflection.MergeTarget
Clears the field. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the field.- Specified by:
clearField
in interfaceMessageReflection.MergeTarget
-
setRepeatedField
public MessageReflection.MergeTarget setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value) Description copied from interface:MessageReflection.MergeTarget
Sets an element of a repeated field to the given value. The value must be of the correct type for this field, i.e. the same type thatMessageOrBuilder.getRepeatedField(Descriptors.FieldDescriptor, int)
would return.- Specified by:
setRepeatedField
in interfaceMessageReflection.MergeTarget
-
addRepeatedField
public MessageReflection.MergeTarget addRepeatedField(Descriptors.FieldDescriptor field, Object value) Description copied from interface:MessageReflection.MergeTarget
LikesetRepeatedField
, but appends the value as a new element.- Specified by:
addRepeatedField
in interfaceMessageReflection.MergeTarget
-
hasOneof
Description copied from interface:MessageReflection.MergeTarget
Returns true if the given oneof is set.- Specified by:
hasOneof
in interfaceMessageReflection.MergeTarget
-
clearOneof
Description copied from interface:MessageReflection.MergeTarget
Clears the oneof. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the oneof.- Specified by:
clearOneof
in interfaceMessageReflection.MergeTarget
-
getOneofFieldDescriptor
Description copied from interface:MessageReflection.MergeTarget
Obtains the FieldDescriptor if the given oneof is set. Returns null if no field is set.- Specified by:
getOneofFieldDescriptor
in interfaceMessageReflection.MergeTarget
-
getContainerType
- Specified by:
getContainerType
in interfaceMessageReflection.MergeTarget
-
findExtensionByName
- Specified by:
findExtensionByName
in interfaceMessageReflection.MergeTarget
-
findExtensionByNumber
public ExtensionRegistry.ExtensionInfo findExtensionByNumber(ExtensionRegistry registry, Descriptors.Descriptor containingType, int fieldNumber) - Specified by:
findExtensionByNumber
in interfaceMessageReflection.MergeTarget
-
parseGroup
public Object parseGroup(CodedInputStream input, ExtensionRegistryLite registry, Descriptors.FieldDescriptor field, Message defaultInstance) throws IOException Description copied from interface:MessageReflection.MergeTarget
Parse the input stream into a sub field group defined based on either FieldDescriptor or the default instance.- Specified by:
parseGroup
in interfaceMessageReflection.MergeTarget
- Throws:
IOException
-
parseMessage
public Object parseMessage(CodedInputStream input, ExtensionRegistryLite registry, Descriptors.FieldDescriptor field, Message defaultInstance) throws IOException Description copied from interface:MessageReflection.MergeTarget
Parse the input stream into a sub field message defined based on either FieldDescriptor or the default instance.- Specified by:
parseMessage
in interfaceMessageReflection.MergeTarget
- Throws:
IOException
-
mergeGroup
public void mergeGroup(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws IOException Description copied from interface:MessageReflection.MergeTarget
Read the given group field from the wire, merging with the existing field if it is already present.For extensions, defaultInstance must be specified. For regular fields, defaultInstance can be null.
- Specified by:
mergeGroup
in interfaceMessageReflection.MergeTarget
- Throws:
IOException
-
mergeMessage
public void mergeMessage(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws IOException Description copied from interface:MessageReflection.MergeTarget
Read the given message field from the wire, merging with the existing field if it is already present.For extensions, defaultInstance must be specified. For regular fields, defaultInstance can be null.
- Specified by:
mergeMessage
in interfaceMessageReflection.MergeTarget
- Throws:
IOException
-
parseMessageFromBytes
public Object parseMessageFromBytes(ByteString bytes, ExtensionRegistryLite registry, Descriptors.FieldDescriptor field, Message defaultInstance) throws IOException Description copied from interface:MessageReflection.MergeTarget
Parse from a ByteString into a sub field message defined based on either FieldDescriptor or the default instance. There isn't a varint indicating the length of the message at the beginning of the input ByteString.- Specified by:
parseMessageFromBytes
in interfaceMessageReflection.MergeTarget
- Throws:
IOException
-
newMergeTargetForField
public MessageReflection.MergeTarget newMergeTargetForField(Descriptors.FieldDescriptor descriptor, Message defaultInstance) Description copied from interface:MessageReflection.MergeTarget
Returns a new merge target for a sub-field. When defaultInstance is provided, it indicates the descriptor is for an extension type, and implementations should create a new instance from the defaultInstance prototype directly.- Specified by:
newMergeTargetForField
in interfaceMessageReflection.MergeTarget
-
newEmptyTargetForField
public MessageReflection.MergeTarget newEmptyTargetForField(Descriptors.FieldDescriptor descriptor, Message defaultInstance) Description copied from interface:MessageReflection.MergeTarget
Returns an empty merge target for a sub-field. When defaultInstance is provided, it indicates the descriptor is for an extension type, and implementations should create a new instance from the defaultInstance prototype directly.- Specified by:
newEmptyTargetForField
in interfaceMessageReflection.MergeTarget
-
getUtf8Validation
Description copied from interface:MessageReflection.MergeTarget
Returns the UTF8 validation level for the field.- Specified by:
getUtf8Validation
in interfaceMessageReflection.MergeTarget
-
finish
Description copied from interface:MessageReflection.MergeTarget
Finishes the merge and returns the underlying object.- Specified by:
finish
in interfaceMessageReflection.MergeTarget
-