Package com.google.protobuf
Class MessageReflection.BuilderAdapter
- java.lang.Object
-
- com.google.protobuf.MessageReflection.BuilderAdapter
-
- All Implemented Interfaces:
MessageReflection.MergeTarget
- Enclosing class:
- MessageReflection
static class MessageReflection.BuilderAdapter extends java.lang.Object implements MessageReflection.MergeTarget
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.protobuf.MessageReflection.MergeTarget
MessageReflection.MergeTarget.ContainerType
-
-
Field Summary
Fields Modifier and Type Field Description private Message.Builder
builder
private boolean
hasNestedBuilders
-
Constructor Summary
Constructors Constructor Description BuilderAdapter(Message.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete 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.private Message.Builder
getFieldBuilder(Descriptors.FieldDescriptor field)
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.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.MessageReflection.MergeTarget
newEmptyTargetForField(Descriptors.FieldDescriptor field, Message defaultInstance)
Returns an empty merge target for a sub-field.MessageReflection.MergeTarget
newMergeTargetForField(Descriptors.FieldDescriptor field, Message defaultInstance)
Returns a new merge target for a sub-field.private Message.Builder
newMessageFieldInstance(Descriptors.FieldDescriptor field, Message defaultInstance)
java.lang.Object
parseGroup(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, 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 extensionRegistry, Descriptors.FieldDescriptor field, 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 extensionRegistry, Descriptors.FieldDescriptor field, 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.
-
-
-
Field Detail
-
builder
private final Message.Builder builder
-
hasNestedBuilders
private boolean hasNestedBuilders
-
-
Constructor Detail
-
BuilderAdapter
public BuilderAdapter(Message.Builder builder)
-
-
Method Detail
-
getDescriptorForType
public Descriptors.Descriptor getDescriptorForType()
Description copied from interface:MessageReflection.MergeTarget
Returns the descriptor for the target.- Specified by:
getDescriptorForType
in interfaceMessageReflection.MergeTarget
-
getField
public java.lang.Object getField(Descriptors.FieldDescriptor field)
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
-
getFieldBuilder
private Message.Builder getFieldBuilder(Descriptors.FieldDescriptor field)
-
hasField
public boolean hasField(Descriptors.FieldDescriptor field)
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
public MessageReflection.MergeTarget setField(Descriptors.FieldDescriptor field, java.lang.Object value)
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
public MessageReflection.MergeTarget clearField(Descriptors.FieldDescriptor field)
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, java.lang.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, java.lang.Object value)
Description copied from interface:MessageReflection.MergeTarget
LikesetRepeatedField
, but appends the value as a new element.- Specified by:
addRepeatedField
in interfaceMessageReflection.MergeTarget
-
hasOneof
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
Description copied from interface:MessageReflection.MergeTarget
Returns true if the given oneof is set.- Specified by:
hasOneof
in interfaceMessageReflection.MergeTarget
-
clearOneof
public MessageReflection.MergeTarget clearOneof(Descriptors.OneofDescriptor oneof)
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
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
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
public MessageReflection.MergeTarget.ContainerType getContainerType()
- Specified by:
getContainerType
in interfaceMessageReflection.MergeTarget
-
findExtensionByName
public ExtensionRegistry.ExtensionInfo findExtensionByName(ExtensionRegistry registry, java.lang.String name)
- 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 java.lang.Object parseGroup(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws java.io.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:
java.io.IOException
-
parseMessage
public java.lang.Object parseMessage(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws java.io.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:
java.io.IOException
-
parseMessageFromBytes
public java.lang.Object parseMessageFromBytes(ByteString bytes, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws java.io.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:
java.io.IOException
-
mergeGroup
public void mergeGroup(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws java.io.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:
java.io.IOException
-
mergeMessage
public void mergeMessage(CodedInputStream input, ExtensionRegistryLite extensionRegistry, Descriptors.FieldDescriptor field, Message defaultInstance) throws java.io.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:
java.io.IOException
-
newMessageFieldInstance
private Message.Builder newMessageFieldInstance(Descriptors.FieldDescriptor field, Message defaultInstance)
-
newMergeTargetForField
public MessageReflection.MergeTarget newMergeTargetForField(Descriptors.FieldDescriptor field, 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 field, 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
public WireFormat.Utf8Validation getUtf8Validation(Descriptors.FieldDescriptor descriptor)
Description copied from interface:MessageReflection.MergeTarget
Returns the UTF8 validation level for the field.- Specified by:
getUtf8Validation
in interfaceMessageReflection.MergeTarget
-
finish
public java.lang.Object finish()
Description copied from interface:MessageReflection.MergeTarget
Finishes the merge and returns the underlying object.- Specified by:
finish
in interfaceMessageReflection.MergeTarget
-
-