Public Member Functions | Private Member Functions | Private Attributes | List of all members
com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder > Class Template Reference
Inheritance diagram for com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >:
Inheritance graph
[legend]

Public Member Functions

MType build ()
 
SingleFieldBuilder< MType, BType, IType > clear ()
 
void dispose ()
 
BType getBuilder ()
 
MType getMessage ()
 
IType getMessageOrBuilder ()
 
void markDirty ()
 
SingleFieldBuilder< MType, BType, IType > mergeFrom (MType value)
 
SingleFieldBuilder< MType, BType, IType > setMessage (MType message)
 
 SingleFieldBuilder (MType message, GeneratedMessage.BuilderParent parent, boolean isClean)
 

Private Member Functions

void onChanged ()
 

Private Attributes

BType builder
 
boolean isClean
 
MType message
 
GeneratedMessage.BuilderParent parent
 

Detailed Description

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.

It also supports the additional use case of setting a Message.Builder as the field and deferring conversion of that

to an immutable

Message

. In this way, it's possible to maintain a tree of

's that acts as a fully read/write data structure.
Logically, one can think of a tree of builders as converting the entire tree to messages when build is called on the root or when any method is called that desires a Message instead of a Builder. In terms of the implementation, the

and

RepeatedFieldBuilder

classes cache messages that were created so that messages only need to be created when some change occurred in its builder or a builder for one of its descendants.

Parameters
<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
Author
jonp@.nosp@m.goog.nosp@m.le.co.nosp@m.m (Jon Perlow)

Definition at line 55 of file SingleFieldBuilder.java.

Constructor & Destructor Documentation

◆ SingleFieldBuilder()

com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.SingleFieldBuilder ( MType  message,
GeneratedMessage.BuilderParent  parent,
boolean  isClean 
)
inline

Definition at line 79 of file SingleFieldBuilder.java.

Member Function Documentation

◆ build()

MType com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.build ( )
inline

Builds the message and returns it.

Returns
the message

Definition at line 111 of file SingleFieldBuilder.java.

◆ clear()

SingleFieldBuilder<MType, BType, IType> com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.clear ( )
inline

Clears the value of the field.

Returns
the builder

Definition at line 191 of file SingleFieldBuilder.java.

◆ dispose()

void com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.dispose ( )
inline

Definition at line 85 of file SingleFieldBuilder.java.

◆ getBuilder()

BType com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getBuilder ( )
inline

Gets a builder for the field. If no builder has been created yet, a builder is created on demand by calling Message#toBuilder.

Returns
The builder for the field

Definition at line 125 of file SingleFieldBuilder.java.

◆ getMessage()

MType com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getMessage ( )
inline

Get the message for the field. If the message is currently stored as a

, 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.

Returns
the message for the field

Definition at line 98 of file SingleFieldBuilder.java.

◆ getMessageOrBuilder()

IType com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getMessageOrBuilder ( )
inline

Gets the base class interface for the field. This may either be a builder or a message. It will return whatever is more efficient.

Returns
the message or builder for the field as the base class interface

Definition at line 145 of file SingleFieldBuilder.java.

◆ markDirty()

void com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.markDirty ( )
inline

A builder becomes dirty whenever a field is modified – including fields in nested builders – and becomes clean when build() is called. Thus, when a builder becomes dirty, all its parents become dirty as well, and when it becomes clean, all its children become clean. The dirtiness state is used to invalidate certain cached values.

To this end, a builder calls markDirty() on its parent whenever it transitions from clean to dirty. The parent must propagate this call to its own parent, unless it was already dirty, in which case the grandparent must necessarily already be dirty as well. The parent can only transition back to "clean" after calling build() on all children.

Implements com.google.protobuf.AbstractMessage.BuilderParent.

Definition at line 224 of file SingleFieldBuilder.java.

◆ mergeFrom()

SingleFieldBuilder<MType, BType, IType> com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.mergeFrom ( MType  value)
inline

Merges the field from another field.

Parameters
valuethe value to merge from
Returns
the builder

Definition at line 175 of file SingleFieldBuilder.java.

◆ onChanged()

void com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.onChanged ( )
inlineprivate

Called when a the builder or one of its nested children has changed and any parent should be notified of its invalidation.

Definition at line 209 of file SingleFieldBuilder.java.

◆ setMessage()

SingleFieldBuilder<MType, BType, IType> com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.setMessage ( MType  message)
inline

Sets a message for the field replacing any existing value.

Parameters
messagethe message to set
Returns
the builder

Definition at line 159 of file SingleFieldBuilder.java.

Member Data Documentation

◆ builder

BType com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.builder
private

Definition at line 69 of file SingleFieldBuilder.java.

◆ isClean

boolean com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.isClean
private

Definition at line 77 of file SingleFieldBuilder.java.

◆ message

Definition at line 73 of file SingleFieldBuilder.java.

◆ parent

GeneratedMessage.BuilderParent com.google.protobuf.SingleFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.parent
private

Definition at line 62 of file SingleFieldBuilder.java.


The documentation for this class was generated from the following file:
com.google.protobuf.SingleFieldBuilder.SingleFieldBuilder
SingleFieldBuilder(MType message, GeneratedMessage.BuilderParent parent, boolean isClean)
Definition: SingleFieldBuilder.java:79
Builder
Definition: ruby/ext/google/protobuf_c/protobuf.h:162


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:07