Package com.google.protobuf
Interface MessageReflection.MergeTarget
- All Known Implementing Classes:
MessageReflection.BuilderAdapter
,MessageReflection.ExtensionAdapter
,MessageReflection.ExtensionBuilderAdapter
- Enclosing class:
MessageReflection
static interface MessageReflection.MergeTarget
-
Nested Class Summary
Nested Classes -
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 descriptor, 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 descriptor, 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 descriptor, 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.
-
Method Details
-
getDescriptorForType
Descriptors.Descriptor getDescriptorForType()Returns the descriptor for the target. -
getContainerType
MessageReflection.MergeTarget.ContainerType getContainerType() -
findExtensionByName
-
findExtensionByNumber
ExtensionRegistry.ExtensionInfo findExtensionByNumber(ExtensionRegistry registry, Descriptors.Descriptor containingType, int fieldNumber) -
getField
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. -
hasField
Returns true if the given field is set. This is exactly equivalent to calling the generated "has" accessor method corresponding to the field.- Throws:
IllegalArgumentException
- The field is a repeated field, orfield.getContainingType() != getDescriptorForType()
.
-
setField
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. -
clearField
Clears the field. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the field. -
setRepeatedField
MessageReflection.MergeTarget setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value) 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.- Throws:
IllegalArgumentException
- The field is not a repeated field, orfield.getContainingType() != getDescriptorForType()
.
-
addRepeatedField
LikesetRepeatedField
, but appends the value as a new element.- Throws:
IllegalArgumentException
- The field is not a repeated field, orfield.getContainingType() != getDescriptorForType()
.
-
hasOneof
Returns true if the given oneof is set.- Throws:
IllegalArgumentException
- ifoneof.getContainingType() != getDescriptorForType()
.
-
clearOneof
Clears the oneof. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the oneof. -
getOneofFieldDescriptor
Obtains the FieldDescriptor if the given oneof is set. Returns null if no field is set. -
parseGroup
Object parseGroup(CodedInputStream input, ExtensionRegistryLite registry, Descriptors.FieldDescriptor descriptor, Message defaultInstance) throws IOException Parse the input stream into a sub field group defined based on either FieldDescriptor or the default instance.- Throws:
IOException
-
parseMessage
Object parseMessage(CodedInputStream input, ExtensionRegistryLite registry, Descriptors.FieldDescriptor descriptor, Message defaultInstance) throws IOException Parse the input stream into a sub field message defined based on either FieldDescriptor or the default instance.- Throws:
IOException
-
parseMessageFromBytes
Object parseMessageFromBytes(ByteString bytes, ExtensionRegistryLite registry, Descriptors.FieldDescriptor descriptor, Message defaultInstance) throws IOException 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.- Throws:
IOException
-
mergeGroup
void mergeGroup(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws IOException 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.
- Throws:
IOException
-
mergeMessage
void mergeMessage(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws IOException 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.
- Throws:
IOException
-
getUtf8Validation
Returns the UTF8 validation level for the field. -
newMergeTargetForField
MessageReflection.MergeTarget newMergeTargetForField(Descriptors.FieldDescriptor descriptor, Message defaultInstance) 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. -
newEmptyTargetForField
MessageReflection.MergeTarget newEmptyTargetForField(Descriptors.FieldDescriptor descriptor, Message defaultInstance) 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. -
finish
Object finish()Finishes the merge and returns the underlying object.
-