public abstract static class GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder extends AbstractMessage> .Builder <BuilderType>
| Modifier | Constructor and Description |
|---|---|
protected |
Builder()
|
protected |
Builder(GeneratedMessage
|
| Modifier and Type | Method and Description |
|---|---|
BuilderType |
addRepeatedField(Descriptors
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
Clears the field.
|
BuilderType |
clearOneof(Descriptors
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
BuilderType |
clone()
Clones the Builder.
|
Map |
getAllFields()
Returns a collection of all the fields in this message which are set and their corresponding values.
|
Descriptors |
getDescriptorForType()
Get the message's type's descriptor.
|
Object |
getField(Descriptors
Obtains the value of the given field, or the default value if it is not set.
|
Message |
getFieldBuilder(Descriptors
Get a nested builder instance for the given field.
|
Descriptors |
getOneofFieldDescriptor(Descriptors
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
protected GeneratedMessage |
getParentForChildren()
Gets the
GeneratedMessage.BuilderParent for giving to our children.
|
Object |
getRepeatedField(Descriptors
Gets an element of a repeated field.
|
int |
getRepeatedFieldCount(Descriptors
Gets the number of elements of a repeated field.
|
UnknownFieldSet |
getUnknownFields()
Get the
UnknownFieldSet for this message.
|
boolean |
hasField(Descriptors
Returns true if the given field is set.
|
boolean |
hasOneof(Descriptors
TODO(jieluo): Clear it when all subclasses have implemented this method.
|
protected abstract GeneratedMessage |
internalGetFieldAccessorTable()
Get the FieldAccessorTable for this type.
|
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
Merge some unknown fields into the
UnknownFieldSet for this message.
|
Message |
newBuilderForField(Descriptors
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.
|
protected boolean |
parseUnknownField(CodedInputStream
Called by subclasses to parse an unknown field.
|
BuilderType |
setField(Descriptors
Sets a field to the given value.
|
BuilderType |
setRepeatedField(Descriptors
Sets an element of a repeated field to the given value.
|
BuilderType |
setUnknownFields(UnknownFieldSet
Set the
UnknownFieldSet for this message.
|
findInitializationErrors, getInitializationErrorString, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toStringaddAll, newUninitializedMessageExceptionequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitbuild, buildPartialgetDefaultInstanceForTypeprotected Builder()
protected Builder(GeneratedMessage.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 GeneratedMessage.Builder >
Object.clone()
public BuilderType clear()
protected abstract GeneratedMessage.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
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 UnsupportedException.
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
AbstractMessage.Builder
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors .OneofDescriptor oneof)
AbstractMessage.Builder
public boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public ObjectgetField(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
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuilder
public ObjectgetRepeatedField(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 final BuilderType setUnknownFields(UnknownFieldSetunknownFields)
Message.Builder
UnknownFieldSet for this message.
public final BuilderType mergeUnknownFields(UnknownFieldSetunknownFields)
Message.Builder
UnknownFieldSet for this message.
public boolean isInitialized()
MessageLiteOrBuilder
public final UnknownFieldSetgetUnknownFields()
MessageOrBuilder
UnknownFieldSet for this message.
protected boolean parseUnknownField(CodedInputStreaminput, UnknownFieldSet .Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws IOException
true unless the tag is an end-group tag.
IOException
protected GeneratedMessage.BuilderParent getParentForChildren()
GeneratedMessage.BuilderParent for giving to our children.
protected final void onChanged()