public abstract static class GeneratedMessage.Builder<BuilderType> extends AbstractMessage.Builder<BuilderType>
Type Parameter |
---|
Name | Description |
BuilderType | |
Constructors
Builder()
Builder(GeneratedMessage.BuilderParent builderParent)
protected Builder(GeneratedMessage.BuilderParent builderParent)
Methods
addRepeatedField(Descriptors.FieldDescriptor field, Object value)
public BuilderType addRepeatedField(Descriptors.FieldDescriptor field, Object value)
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)
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.
Returns |
---|
Type | Description |
BuilderType | |
Overrides
clone()
public BuilderType clone()
Returns |
---|
Type | Description |
BuilderType | |
Overrides
getAllFields()
public Map<Descriptors.FieldDescriptor,Object> getAllFields()
getDescriptorForType()
public Descriptors.Descriptor getDescriptorForType()
getField(Descriptors.FieldDescriptor field)
public Object getField(Descriptors.FieldDescriptor field)
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
.
Overrides
getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
Overrides
getParentForChildren()
protected GeneratedMessage.BuilderParent getParentForChildren()
Gets the BuilderParent for giving to our children.
getRepeatedField(Descriptors.FieldDescriptor field, int index)
public Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
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
.
Overrides
getRepeatedFieldCount(Descriptors.FieldDescriptor field)
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Returns |
---|
Type | Description |
int | |
getUnknownFields()
public final UnknownFieldSet getUnknownFields()
hasField(Descriptors.FieldDescriptor field)
public boolean hasField(Descriptors.FieldDescriptor field)
hasOneof(Descriptors.OneofDescriptor oneof)
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
Overrides
internalGetFieldAccessorTable()
protected abstract GeneratedMessage.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.
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
|
internalGetMutableMapField(int fieldNumber)
protected MapField internalGetMutableMapField(int fieldNumber)
Like #internalGetMapField but return a mutable version.
Parameter |
---|
Name | Description |
fieldNumber | int
|
isClean()
protected boolean isClean()
Gets whether invalidations are needed
Returns |
---|
Type | Description |
boolean | whether invalidations are needed
|
isInitialized()
public boolean isInitialized()
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)
Returns |
---|
Type | Description |
BuilderType | |
Overrides
newBuilderForField(Descriptors.FieldDescriptor field)
public Message.Builder newBuilderForField(Descriptors.FieldDescriptor field)
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.
protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag)
Called by subclasses to parse an unknown field.
Returns |
---|
Type | Description |
boolean | true unless the tag is an end-group tag.
|
setField(Descriptors.FieldDescriptor field, Object value)
public BuilderType setField(Descriptors.FieldDescriptor field, Object value)
Returns |
---|
Type | Description |
BuilderType | |
setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
public BuilderType setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Returns |
---|
Type | Description |
BuilderType | |
setUnknownFields(UnknownFieldSet unknownFields)
public BuilderType setUnknownFields(UnknownFieldSet unknownFields)
Returns |
---|
Type | Description |
BuilderType | |