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.Builderbuilderprivate booleanhasNestedBuilders
-
Constructor Summary
Constructors Constructor Description BuilderAdapter(Message.Builder builder)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description MessageReflection.MergeTargetaddRepeatedField(Descriptors.FieldDescriptor field, java.lang.Object value)LikesetRepeatedField, but appends the value as a new element.MessageReflection.MergeTargetclearField(Descriptors.FieldDescriptor field)Clears the field.MessageReflection.MergeTargetclearOneof(Descriptors.OneofDescriptor oneof)Clears the oneof.ExtensionRegistry.ExtensionInfofindExtensionByName(ExtensionRegistry registry, java.lang.String name)ExtensionRegistry.ExtensionInfofindExtensionByNumber(ExtensionRegistry registry, Descriptors.Descriptor containingType, int fieldNumber)java.lang.Objectfinish()Finishes the merge and returns the underlying object.MessageReflection.MergeTarget.ContainerTypegetContainerType()Descriptors.DescriptorgetDescriptorForType()Returns the descriptor for the target.java.lang.ObjectgetField(Descriptors.FieldDescriptor field)Obtains the value of the given field, or the default value if it is not set.private Message.BuildergetFieldBuilder(Descriptors.FieldDescriptor field)Descriptors.FieldDescriptorgetOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)Obtains the FieldDescriptor if the given oneof is set.WireFormat.Utf8ValidationgetUtf8Validation(Descriptors.FieldDescriptor descriptor)Returns the UTF8 validation level for the field.booleanhasField(Descriptors.FieldDescriptor field)Returns true if the given field is set.booleanhasOneof(Descriptors.OneofDescriptor oneof)Returns true if the given oneof is set.voidmergeGroup(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.voidmergeMessage(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.MergeTargetnewEmptyTargetForField(Descriptors.FieldDescriptor field, Message defaultInstance)Returns an empty merge target for a sub-field.MessageReflection.MergeTargetnewMergeTargetForField(Descriptors.FieldDescriptor field, Message defaultInstance)Returns a new merge target for a sub-field.private Message.BuildernewMessageFieldInstance(Descriptors.FieldDescriptor field, Message defaultInstance)java.lang.ObjectparseGroup(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.ObjectparseMessage(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.ObjectparseMessageFromBytes(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.MergeTargetsetField(Descriptors.FieldDescriptor field, java.lang.Object value)Sets a field to the given value.MessageReflection.MergeTargetsetRepeatedField(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.MergeTargetReturns the descriptor for the target.- Specified by:
getDescriptorForTypein interfaceMessageReflection.MergeTarget
-
getField
public java.lang.Object getField(Descriptors.FieldDescriptor field)
Description copied from interface:MessageReflection.MergeTargetObtains 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:
getFieldin interfaceMessageReflection.MergeTarget
-
getFieldBuilder
private Message.Builder getFieldBuilder(Descriptors.FieldDescriptor field)
-
hasField
public boolean hasField(Descriptors.FieldDescriptor field)
Description copied from interface:MessageReflection.MergeTargetReturns true if the given field is set. This is exactly equivalent to calling the generated "has" accessor method corresponding to the field.- Specified by:
hasFieldin interfaceMessageReflection.MergeTarget
-
setField
public MessageReflection.MergeTarget setField(Descriptors.FieldDescriptor field, java.lang.Object value)
Description copied from interface:MessageReflection.MergeTargetSets 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:
setFieldin interfaceMessageReflection.MergeTarget
-
clearField
public MessageReflection.MergeTarget clearField(Descriptors.FieldDescriptor field)
Description copied from interface:MessageReflection.MergeTargetClears the field. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the field.- Specified by:
clearFieldin interfaceMessageReflection.MergeTarget
-
setRepeatedField
public MessageReflection.MergeTarget setRepeatedField(Descriptors.FieldDescriptor field, int index, java.lang.Object value)
Description copied from interface:MessageReflection.MergeTargetSets 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:
setRepeatedFieldin interfaceMessageReflection.MergeTarget
-
addRepeatedField
public MessageReflection.MergeTarget addRepeatedField(Descriptors.FieldDescriptor field, java.lang.Object value)
Description copied from interface:MessageReflection.MergeTargetLikesetRepeatedField, but appends the value as a new element.- Specified by:
addRepeatedFieldin interfaceMessageReflection.MergeTarget
-
hasOneof
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
Description copied from interface:MessageReflection.MergeTargetReturns true if the given oneof is set.- Specified by:
hasOneofin interfaceMessageReflection.MergeTarget
-
clearOneof
public MessageReflection.MergeTarget clearOneof(Descriptors.OneofDescriptor oneof)
Description copied from interface:MessageReflection.MergeTargetClears the oneof. This is exactly equivalent to calling the generated "clear" accessor method corresponding to the oneof.- Specified by:
clearOneofin interfaceMessageReflection.MergeTarget
-
getOneofFieldDescriptor
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
Description copied from interface:MessageReflection.MergeTargetObtains the FieldDescriptor if the given oneof is set. Returns null if no field is set.- Specified by:
getOneofFieldDescriptorin interfaceMessageReflection.MergeTarget
-
getContainerType
public MessageReflection.MergeTarget.ContainerType getContainerType()
- Specified by:
getContainerTypein interfaceMessageReflection.MergeTarget
-
findExtensionByName
public ExtensionRegistry.ExtensionInfo findExtensionByName(ExtensionRegistry registry, java.lang.String name)
- Specified by:
findExtensionByNamein interfaceMessageReflection.MergeTarget
-
findExtensionByNumber
public ExtensionRegistry.ExtensionInfo findExtensionByNumber(ExtensionRegistry registry, Descriptors.Descriptor containingType, int fieldNumber)
- Specified by:
findExtensionByNumberin 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.MergeTargetParse the input stream into a sub field group defined based on either FieldDescriptor or the default instance.- Specified by:
parseGroupin 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.MergeTargetParse the input stream into a sub field message defined based on either FieldDescriptor or the default instance.- Specified by:
parseMessagein 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.MergeTargetParse 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:
parseMessageFromBytesin 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.MergeTargetRead 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:
mergeGroupin 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.MergeTargetRead 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:
mergeMessagein 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.MergeTargetReturns 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:
newMergeTargetForFieldin interfaceMessageReflection.MergeTarget
-
newEmptyTargetForField
public MessageReflection.MergeTarget newEmptyTargetForField(Descriptors.FieldDescriptor field, Message defaultInstance)
Description copied from interface:MessageReflection.MergeTargetReturns 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:
newEmptyTargetForFieldin interfaceMessageReflection.MergeTarget
-
getUtf8Validation
public WireFormat.Utf8Validation getUtf8Validation(Descriptors.FieldDescriptor descriptor)
Description copied from interface:MessageReflection.MergeTargetReturns the UTF8 validation level for the field.- Specified by:
getUtf8Validationin interfaceMessageReflection.MergeTarget
-
finish
public java.lang.Object finish()
Description copied from interface:MessageReflection.MergeTargetFinishes the merge and returns the underlying object.- Specified by:
finishin interfaceMessageReflection.MergeTarget
-
-