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