MType - the type of message for the field
BType - the type of builder for the field
IType - the common interface for the message and the builder
public class SingleFieldBuilder<MType extends GeneratedMessageextends Object ,BType extends GeneratedMessage .Builder ,IType extends MessageOrBuilder > implements GeneratedMessage .BuilderParent
SingleFieldBuilder implements a structure that a protocol message uses to hold a single field of another protocol message. It supports the classical use case of setting an immutable
Message as the value of the field and is highly optimized around this.
Message.Builder as the field and deferring conversion of that
Builder to an immutable
Message. In this way, it's possible to maintain a tree of
Builder's that acts as a fully read/write data structure.
SingleFieldBuilder and
RepeatedFieldBuilder classes cache messages that were created so that messages only need to be created when some change occured in its builder or a builder for one of its descendants.
| Constructor and Description |
|---|
SingleFieldBuilder(MType message, GeneratedMessage
|
| Modifier and Type | Method and Description |
|---|---|
MType |
build()
Builds the message and returns it.
|
SingleFieldBuilder |
clear()
Clears the value of the field.
|
void |
dispose()
|
BType |
getBuilder()
Gets a builder for the field.
|
MType |
getMessage()
Get the message for the field.
|
IType |
getMessageOrBuilder()
Gets the base class interface for the field.
|
void |
markDirty()
A builder becomes dirty whenever a field is modified -- including fields in nested builders -- and becomes clean when build() is called.
|
SingleFieldBuilder |
mergeFrom(MType value)
Merges the field from another field.
|
SingleFieldBuilder |
setMessage(MType message)
Sets a message for the field replacing any existing value.
|
public SingleFieldBuilder(MType message, GeneratedMessage.BuilderParent parent, boolean isClean)
public void dispose()
public MType getMessage()
Builder, it is converted to a
Message by calling
Message.Builder.buildPartial() on it. If no message has been set, returns the default instance of the message.
public MType build()
public BType getBuilder()
Message.toBuilder() .
public IType getMessageOrBuilder()
public SingleFieldBuilder<MType ,BType ,IType> setMessage(MType message)
message - the message to set
public SingleFieldBuilder<MType ,BType ,IType> mergeFrom(MType value)
value - the value to merge from
public SingleFieldBuilder<MType ,BType ,IType> clear()
public void markDirty()
GeneratedMessage.BuilderParent