public abstract static class GeneratedMessageV3.Builder<BuilderType> extends AbstractMessage.Builder<BuilderType>
Type Parameter
Name | Description |
BuilderType | |
Constructors
Builder()
Builder(GeneratedMessageV3.BuilderParent builderParent)
protected Builder(GeneratedMessageV3.BuilderParent builderParent)
Parameter
Methods
addRepeatedField(Descriptors.FieldDescriptor field, Object value)
public BuilderType addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Parameters
Returns
Type | Description |
BuilderType | |
clear()
public BuilderType clear()
Called by the initialization and clear code paths to allow subclasses to
reset any of their builtin fields back to the initial values.
Returns
Type | Description |
BuilderType | |
Overrides
clearField(Descriptors.FieldDescriptor field)
public BuilderType clearField(Descriptors.FieldDescriptor field)
Parameter
Returns
Type | Description |
BuilderType | |
clearOneof(Descriptors.OneofDescriptor oneof)
public BuilderType clearOneof(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
Parameter
Returns
Type | Description |
BuilderType | |
Overrides
clone()
public BuilderType clone()
Returns
Type | Description |
BuilderType | |
Overrides
getAllFields()
public Map<Descriptors.FieldDescriptor,Object> getAllFields()
Returns
getDescriptorForType()
public Descriptors.Descriptor getDescriptorForType()
Returns
getField(Descriptors.FieldDescriptor field)
public Object getField(Descriptors.FieldDescriptor field)
Parameter
Returns
getFieldBuilder(Descriptors.FieldDescriptor field)
public Message.Builder getFieldBuilder(Descriptors.FieldDescriptor field)
Get a nested builder instance for the given field.
Normally, we hold a reference to the immutable message object for the message type field.
Some implementations(the generated message builders), however, can also hold a reference to
the builder object (a nested builder) for the field.
If the field is already backed up by a nested builder, the nested builder will be
returned. Otherwise, a new field builder will be created and returned. The original message
field (if exist) will be merged into the field builder, which will then be nested into its
parent builder.
NOTE: implementations that do not support nested builders will throw
UnsupportedOperationException
.
Parameter
Returns
Overrides
getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
Parameter
Returns
Overrides
getParentForChildren()
protected GeneratedMessageV3.BuilderParent getParentForChildren()
Gets the BuilderParent for giving to our children.
Returns
getRepeatedField(Descriptors.FieldDescriptor field, int index)
public Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
Parameters
Returns
getRepeatedFieldBuilder(Descriptors.FieldDescriptor field, int index)
public Message.Builder getRepeatedFieldBuilder(Descriptors.FieldDescriptor field, int index)
Get a nested builder instance for the given repeated field instance.
Normally, we hold a reference to the immutable message object for the message type field.
Some implementations(the generated message builders), however, can also hold a reference to
the builder object (a nested builder) for the field.
If the field is already backed up by a nested builder, the nested builder will be
returned. Otherwise, a new field builder will be created and returned. The original message
field (if exist) will be merged into the field builder, which will then be nested into its
parent builder.
NOTE: implementations that do not support nested builders will throw
UnsupportedOperationException
.
Parameters
Returns
Overrides
getRepeatedFieldCount(Descriptors.FieldDescriptor field)
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Parameter
Returns
getUnknownFields()
public final UnknownFieldSet getUnknownFields()
Returns
hasField(Descriptors.FieldDescriptor field)
public boolean hasField(Descriptors.FieldDescriptor field)
Parameter
Returns
hasOneof(Descriptors.OneofDescriptor oneof)
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
Parameter
Returns
Overrides
internalGetFieldAccessorTable()
protected abstract GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type. We can't have the message
class pass this in to the constructor because of bootstrapping trouble
with DescriptorProtos.
Returns
internalGetMapField(int fieldNumber)
protected MapField internalGetMapField(int fieldNumber)
Gets the map field with the given field number. This method should be
overridden in the generated message class if the message contains map
fields.
Unlike other field types, reflection support for map fields can't be
implemented based on generated public API because we need to access a
map field as a list in reflection API but the generated API only allows
us to access it as a map. This method returns the underlying map field
directly and thus enables us to access the map field as a list.
Parameter
Name | Description |
fieldNumber | int
|
Returns
internalGetMutableMapField(int fieldNumber)
protected MapField internalGetMutableMapField(int fieldNumber)
Like #internalGetMapField but return a mutable version.
Parameter
Name | Description |
fieldNumber | int
|
Returns
isClean()
protected boolean isClean()
Gets whether invalidations are needed
Returns
Type | Description |
boolean | whether invalidations are needed
|
isInitialized()
public boolean isInitialized()
Returns
markClean()
protected void markClean()
Called by the subclass or a builder to notify us that a message was
built and may be cached and therefore invalidations are needed.
mergeUnknownFields(UnknownFieldSet unknownFields)
public BuilderType mergeUnknownFields(UnknownFieldSet unknownFields)
Parameter
Returns
Type | Description |
BuilderType | |
Overrides
newBuilderForField(Descriptors.FieldDescriptor field)
public Message.Builder newBuilderForField(Descriptors.FieldDescriptor field)
Parameter
Returns
onBuilt()
Called by the subclass when a message is built.
onChanged()
protected final void onChanged()
Called when a the builder or one of its nested children has changed
and any parent should be notified of its invalidation.
setField(Descriptors.FieldDescriptor field, Object value)
public BuilderType setField(Descriptors.FieldDescriptor field, Object value)
Parameters
Returns
Type | Description |
BuilderType | |
setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
public BuilderType setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Parameters
Returns
Type | Description |
BuilderType | |
setUnknownFields(UnknownFieldSet unknownFields)
public BuilderType setUnknownFields(UnknownFieldSet unknownFields)
Parameter
Returns
Type | Description |
BuilderType | |
setUnknownFieldsProto3(UnknownFieldSet unknownFields)
protected BuilderType setUnknownFieldsProto3(UnknownFieldSet unknownFields)
This method is obsolete, but we must retain it for compatibility with
older generated code.
Parameter
Returns
Type | Description |
BuilderType | |