public abstract static class GeneratedMessageV3.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>> extends AbstractMessage.Builder<BuilderType>
Modifier | Constructor and Description |
---|---|
protected |
Builder() |
protected |
Builder(GeneratedMessageV3.BuilderParent builderParent) |
Modifier and Type | Method and Description |
---|---|
BuilderType |
addRepeatedField(Descriptors.FieldDescriptor field,
Object value)
Like
setRepeatedField , but appends the value as a new element. |
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.
|
BuilderType |
clearField(Descriptors.FieldDescriptor field)
Clears the field.
|
BuilderType |
clearOneof(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
BuilderType |
clone()
Clones the Builder.
|
Map<Descriptors.FieldDescriptor,Object> |
getAllFields()
Returns a collection of all the fields in this message which are set and their corresponding
values.
|
Descriptors.Descriptor |
getDescriptorForType()
Get the message's type's descriptor.
|
Object |
getField(Descriptors.FieldDescriptor field)
Obtains the value of the given field, or the default value if it is not set.
|
Message.Builder |
getFieldBuilder(Descriptors.FieldDescriptor field)
Get a nested builder instance for the given field.
|
Descriptors.FieldDescriptor |
getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
protected GeneratedMessageV3.BuilderParent |
getParentForChildren()
Gets the
GeneratedMessageV3.BuilderParent for giving to our children. |
Object |
getRepeatedField(Descriptors.FieldDescriptor field,
int index)
Gets an element of a repeated field.
|
Message.Builder |
getRepeatedFieldBuilder(Descriptors.FieldDescriptor field,
int index)
Get a nested builder instance for the given repeated field instance.
|
int |
getRepeatedFieldCount(Descriptors.FieldDescriptor field)
Gets the number of elements of a repeated field.
|
UnknownFieldSet |
getUnknownFields()
Get the
UnknownFieldSet for this message. |
boolean |
hasField(Descriptors.FieldDescriptor field)
Returns true if the given field is set.
|
boolean |
hasOneof(Descriptors.OneofDescriptor oneof)
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
protected abstract GeneratedMessageV3.FieldAccessorTable |
internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type.
|
protected MapField |
internalGetMapField(int fieldNumber)
Gets the map field with the given field number.
|
protected MapField |
internalGetMutableMapField(int fieldNumber)
Like
internalGetMapField(int) but return a mutable version. |
protected boolean |
isClean()
Gets whether invalidations are needed
|
boolean |
isInitialized()
Returns true if all required fields in the message and all embedded messages are set, false
otherwise.
|
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.
|
BuilderType |
mergeUnknownFields(UnknownFieldSet unknownFields)
Merge some unknown fields into the
UnknownFieldSet for this message. |
Message.Builder |
newBuilderForField(Descriptors.FieldDescriptor field)
Create a builder for messages of the appropriate type for the given field.
|
protected void |
onBuilt()
Called by the subclass when a message is built.
|
protected void |
onChanged()
Called when a the builder or one of its nested children has changed
and any parent should be notified of its invalidation.
|
BuilderType |
setField(Descriptors.FieldDescriptor field,
Object value)
Sets a field to the given value.
|
BuilderType |
setRepeatedField(Descriptors.FieldDescriptor field,
int index,
Object value)
Sets an element of a repeated field to the given value.
|
BuilderType |
setUnknownFields(UnknownFieldSet unknownFields)
Set the
UnknownFieldSet for this message. |
protected BuilderType |
setUnknownFieldsProto3(UnknownFieldSet unknownFields)
This method is obsolete, but we must retain it for compatibility with
older generated code.
|
findInitializationErrors, getInitializationErrorString, internalMergeFrom, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toString
addAll, addAll, mergeFrom, newUninitializedMessageException
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
build, buildPartial
mergeFrom
getDefaultInstanceForType
protected Builder()
protected Builder(GeneratedMessageV3.BuilderParent builderParent)
protected void onBuilt()
protected void markClean()
protected boolean isClean()
public BuilderType clone()
MessageLite.Builder
clone
in interface Message.Builder
clone
in interface MessageLite.Builder
clone
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
Object.clone()
public BuilderType clear()
clear
in interface Message.Builder
clear
in interface MessageLite.Builder
clear
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
protected abstract GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
public Descriptors.Descriptor getDescriptorForType()
Message.Builder
MessageOrBuilder.getDescriptorForType()
.public Map<Descriptors.FieldDescriptor,Object> getAllFields()
MessageOrBuilder
MessageOrBuilder.getField(Descriptors.FieldDescriptor)
for each field. The map is guaranteed to be a sorted map, so iterating over it will return
fields in order by field number. public Message.Builder newBuilderForField(Descriptors.FieldDescriptor field)
Message.Builder
Message.Builder.setField(Descriptors.FieldDescriptor, Object)
,
Message.Builder.setRepeatedField(Descriptors.FieldDescriptor, int, Object)
, or
Message.Builder.addRepeatedField(Descriptors.FieldDescriptor, Object)
method of the current builder.
To obtain a builder nested in the current builder, use
Message.Builder.getFieldBuilder(Descriptors.FieldDescriptor)
instead.
public Message.Builder getFieldBuilder(Descriptors.FieldDescriptor field)
Message.Builder
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
.
getFieldBuilder
in interface Message.Builder
getFieldBuilder
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
public Message.Builder getRepeatedFieldBuilder(Descriptors.FieldDescriptor field, int index)
Message.Builder
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
.
getRepeatedFieldBuilder
in interface Message.Builder
getRepeatedFieldBuilder
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
AbstractMessage.Builder
hasOneof
in interface MessageOrBuilder
hasOneof
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
AbstractMessage.Builder
getOneofFieldDescriptor
in interface MessageOrBuilder
getOneofFieldDescriptor
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
public boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public Object getField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public BuilderType setField(Descriptors.FieldDescriptor field, Object value)
Message.Builder
MessageOrBuilder.getField(Descriptors.FieldDescriptor)
would return.public BuilderType clearField(Descriptors.FieldDescriptor field)
Message.Builder
public BuilderType clearOneof(Descriptors.OneofDescriptor oneof)
AbstractMessage.Builder
clearOneof
in interface Message.Builder
clearOneof
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuilder
public Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
MessageOrBuilder
public BuilderType setRepeatedField(Descriptors.FieldDescriptor field, int index, Object value)
Message.Builder
MessageOrBuilder.getRepeatedField(Descriptors.FieldDescriptor,int)
would return.public BuilderType addRepeatedField(Descriptors.FieldDescriptor field, Object value)
Message.Builder
setRepeatedField
, but appends the value as a new element.public BuilderType setUnknownFields(UnknownFieldSet unknownFields)
Message.Builder
UnknownFieldSet
for this message.protected BuilderType setUnknownFieldsProto3(UnknownFieldSet unknownFields)
public BuilderType mergeUnknownFields(UnknownFieldSet unknownFields)
Message.Builder
UnknownFieldSet
for this message.mergeUnknownFields
in interface Message.Builder
mergeUnknownFields
in class AbstractMessage.Builder<BuilderType extends GeneratedMessageV3.Builder<BuilderType>>
public boolean isInitialized()
MessageLiteOrBuilder
public final UnknownFieldSet getUnknownFields()
MessageOrBuilder
UnknownFieldSet
for this message.protected GeneratedMessageV3.BuilderParent getParentForChildren()
GeneratedMessageV3.BuilderParent
for giving to our children.protected final void onChanged()
protected MapField internalGetMapField(int fieldNumber)
protected MapField internalGetMutableMapField(int fieldNumber)
internalGetMapField(int)
but return a mutable version.Copyright © 2008–2021. All rights reserved.