public abstract static class GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder> extends AbstractMessage.Builder<BuilderType>
Modifier | Constructor and Description |
---|---|
protected |
GeneratedMessage.Builder() |
protected |
GeneratedMessage.Builder(GeneratedMessage.BuilderParent builderParent) |
Modifier and Type | Method and Description |
---|---|
BuilderType |
addRepeatedField(Descriptors.FieldDescriptor field,
java.lang.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)
|
BuilderType |
clone()
Clones the Builder.
|
java.util.Map<Descriptors.FieldDescriptor,java.lang.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.
|
java.lang.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)
|
protected GeneratedMessage.BuilderParent |
getParentForChildren()
Gets the
GeneratedMessage.BuilderParent for giving to our children. |
java.lang.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)
|
protected abstract GeneratedMessage.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.
|
protected boolean |
parseUnknownField(CodedInputStream input,
UnknownFieldSet.Builder unknownFields,
ExtensionRegistryLite extensionRegistry,
int tag)
Called by subclasses to parse an unknown field.
|
BuilderType |
setField(Descriptors.FieldDescriptor field,
java.lang.Object value)
Sets a field to the given value.
|
BuilderType |
setRepeatedField(Descriptors.FieldDescriptor field,
int index,
java.lang.Object value)
Sets an element of a repeated field to the given value.
|
BuilderType |
setUnknownFields(UnknownFieldSet unknownFields)
Set the
UnknownFieldSet for this message. |
findInitializationErrors, getInitializationErrorString, mergeDelimitedFrom, mergeDelimitedFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, mergeFrom, newUninitializedMessageException, toString
addAll, newUninitializedMessageException
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
build, buildPartial
getDefaultInstanceForType
protected GeneratedMessage.Builder()
protected GeneratedMessage.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()
clear
in interface Message.Builder
clear
in interface MessageLite.Builder
clear
in class AbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
protected abstract GeneratedMessage.FieldAccessorTable internalGetFieldAccessorTable()
public Descriptors.Descriptor getDescriptorForType()
Message.Builder
MessageOrBuilder.getDescriptorForType()
.public java.util.Map<Descriptors.FieldDescriptor,java.lang.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
UnsupportedOperationException
.
getFieldBuilder
in interface Message.Builder
getFieldBuilder
in class AbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
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 GeneratedMessage.Builder>
public boolean hasOneof(Descriptors.OneofDescriptor oneof)
AbstractMessage.Builder
hasOneof
in interface MessageOrBuilder
hasOneof
in class AbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
public Descriptors.FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof)
AbstractMessage.Builder
getOneofFieldDescriptor
in interface MessageOrBuilder
getOneofFieldDescriptor
in class AbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
public boolean hasField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public java.lang.Object getField(Descriptors.FieldDescriptor field)
MessageOrBuilder
public BuilderType setField(Descriptors.FieldDescriptor field, java.lang.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 GeneratedMessage.Builder>
public int getRepeatedFieldCount(Descriptors.FieldDescriptor field)
MessageOrBuilder
public java.lang.Object getRepeatedField(Descriptors.FieldDescriptor field, int index)
MessageOrBuilder
public BuilderType setRepeatedField(Descriptors.FieldDescriptor field, int index, java.lang.Object value)
Message.Builder
MessageOrBuilder.getRepeatedField(Descriptors.FieldDescriptor,int)
would
return.public BuilderType addRepeatedField(Descriptors.FieldDescriptor field, java.lang.Object value)
Message.Builder
setRepeatedField
, but appends the value as a new element.public BuilderType setUnknownFields(UnknownFieldSet unknownFields)
Message.Builder
UnknownFieldSet
for this message.public BuilderType mergeUnknownFields(UnknownFieldSet unknownFields)
Message.Builder
UnknownFieldSet
for this
message.mergeUnknownFields
in interface Message.Builder
mergeUnknownFields
in class AbstractMessage.Builder<BuilderType extends GeneratedMessage.Builder>
public boolean isInitialized()
MessageLiteOrBuilder
public final UnknownFieldSet getUnknownFields()
MessageOrBuilder
UnknownFieldSet
for this message.protected boolean parseUnknownField(CodedInputStream input, UnknownFieldSet.Builder unknownFields, ExtensionRegistryLite extensionRegistry, int tag) throws java.io.IOException
true
unless the tag is an end-group tag.java.io.IOException
protected GeneratedMessage.BuilderParent getParentForChildren()
GeneratedMessage.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.