public abstract static class GeneratedMessage.Builder<BuilderType extends GeneratedMessage.Builder> extends AbstractMessage.Builder<BuilderType>
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 |
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.
|
java.lang.Object |
getRepeatedField(Descriptors.FieldDescriptor field,
int index)
Gets an element of a repeated field.
|
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 |
isInitialized()
Returns true if all required fields in the message and all embedded
messages are set, false otherwise.
|
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.
|
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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
build, buildPartial
getDefaultInstanceForType
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>
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
UnsupportedException
.
getFieldBuilder
in interface Message.Builder
getFieldBuilder
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 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 final BuilderType setUnknownFields(UnknownFieldSet unknownFields)
Message.Builder
UnknownFieldSet
for this message.public final 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.