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

Classes

class  BuilderExternalList
 
class  MessageExternalList
 
class  MessageOrBuilderExternalList
 

Public Member Functions

RepeatedFieldBuilder< MType, BType, IType > addAllMessages (Iterable<? extends MType > values)
 
BType addBuilder (int index, MType message)
 
BType addBuilder (MType message)
 
RepeatedFieldBuilder< MType, BType, IType > addMessage (int index, MType message)
 
RepeatedFieldBuilder< MType, BType, IType > addMessage (MType message)
 
List< MType > build ()
 
void clear ()
 
void dispose ()
 
BType getBuilder (int index)
 
List< BType > getBuilderList ()
 
int getCount ()
 
MType getMessage (int index)
 
List< MType > getMessageList ()
 
IType getMessageOrBuilder (int index)
 
List< IType > getMessageOrBuilderList ()
 
boolean isEmpty ()
 
void markDirty ()
 
void remove (int index)
 
 RepeatedFieldBuilder (List< MType > messages, boolean isMessagesListMutable, GeneratedMessage.BuilderParent parent, boolean isClean)
 
RepeatedFieldBuilder< MType, BType, IType > setMessage (int index, MType message)
 

Private Member Functions

void ensureBuilders ()
 
void ensureMutableMessageList ()
 
MType getMessage (int index, boolean forBuild)
 
void incrementModCounts ()
 
void onChanged ()
 

Private Attributes

List< SingleFieldBuilder< MType, BType, IType > > builders
 
BuilderExternalList< MType, BType, IType > externalBuilderList
 
MessageExternalList< MType, BType, IType > externalMessageList
 
MessageOrBuilderExternalList< MType, BType, IType > externalMessageOrBuilderList
 
boolean isClean
 
boolean isMessagesListMutable
 
List< MType > messages
 
GeneratedMessage.BuilderParent parent
 

Detailed Description

implements a structure that a protocol message uses to hold a repeated field of other protocol messages. It supports the classical use case of adding immutable Message's to the repeated field and is highly optimized around this (no extra memory allocations and sharing of immutable arrays).
It also supports the additional use case of adding a Message.Builder to the repeated 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

SingleFieldBuilder

and

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 61 of file RepeatedFieldBuilder.java.

Constructor & Destructor Documentation

◆ RepeatedFieldBuilder()

com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.RepeatedFieldBuilder ( List< MType >  messages,
boolean  isMessagesListMutable,
GeneratedMessage.BuilderParent  parent,
boolean  isClean 
)
inline

Constructs a new builder with an empty list of messages.

Parameters
messagesthe current list of messages
isMessagesListMutableWhether the messages list is mutable
parenta listener to notify of changes
isCleanwhether the builder is initially marked clean

Definition at line 126 of file RepeatedFieldBuilder.java.

Member Function Documentation

◆ addAllMessages()

RepeatedFieldBuilder<MType, BType, IType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.addAllMessages ( Iterable<? extends MType >  values)
inline

Appends all of the messages in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator.

Parameters
valuesthe messages to add
Returns
the builder

Definition at line 340 of file RepeatedFieldBuilder.java.

◆ addBuilder() [1/2]

BType com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.addBuilder ( int  index,
MType  message 
)
inline

Inserts a new builder at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters
indexthe index at which to insert the builder
messagethe message to add which is the basis of the builder
Returns
the builder

Definition at line 397 of file RepeatedFieldBuilder.java.

◆ addBuilder() [2/2]

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

Appends a new builder to the end of this list and returns the builder.

Parameters
messagethe message to add which is the basis of the builder
Returns
the new builder

Definition at line 377 of file RepeatedFieldBuilder.java.

◆ addMessage() [1/2]

RepeatedFieldBuilder<MType, BType, IType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.addMessage ( int  index,
MType  message 
)
inline

Inserts the specified message at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters
indexthe index at which to insert the message
messagethe message to add
Returns
the builder

Definition at line 321 of file RepeatedFieldBuilder.java.

◆ addMessage() [2/2]

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

Appends the specified element to the end of this list.

Parameters
messagethe message to add
Returns
the builder

Definition at line 300 of file RepeatedFieldBuilder.java.

◆ build()

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

Builds the list of messages from the builder and returns them.

Returns
an immutable list of messages

Definition at line 450 of file RepeatedFieldBuilder.java.

◆ clear()

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

Removes all of the elements from this list. The list will be empty after this call returns.

Definition at line 430 of file RepeatedFieldBuilder.java.

◆ dispose()

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

Definition at line 137 of file RepeatedFieldBuilder.java.

◆ ensureBuilders()

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

Ensures that the list of builders is not null. If it's null, the list is created and initialized to be the same size as the messages list with null entries.

Definition at line 157 of file RepeatedFieldBuilder.java.

◆ ensureMutableMessageList()

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

Ensures that the list of messages is mutable so it can be updated. If it's immutable, a copy is made.

Definition at line 146 of file RepeatedFieldBuilder.java.

◆ getBuilder()

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

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

Parameters
indexthe index of the message to get
Returns
The builder for that index

Definition at line 233 of file RepeatedFieldBuilder.java.

◆ getBuilderList()

List<BType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getBuilderList ( )
inline

Gets a view of the builder as a list of builders. This returned list is live and will reflect any changes to the underlying builder.

Returns
the builders in the list

Definition at line 512 of file RepeatedFieldBuilder.java.

◆ getCount()

int com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getCount ( )
inline

Gets the count of items in the list.

Returns
the count of items in the list.

Definition at line 171 of file RepeatedFieldBuilder.java.

◆ getMessage() [1/2]

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

Get the message at the specified index. If the message is currently stored as a

, it is converted to a

Message

by calling Message.Builder#buildPartial on it.

Parameters
indexthe index of the message to get
Returns
the message for the specified index

Definition at line 192 of file RepeatedFieldBuilder.java.

◆ getMessage() [2/2]

MType com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getMessage ( int  index,
boolean  forBuild 
)
inlineprivate

Get the message at the specified index. If the message is currently stored as a

, it is converted to a

Message

by calling Message.Builder#buildPartial on it.

Parameters
indexthe index of the message to get
forBuildthis is being called for build so we want to make sure we SingleFieldBuilder.build to send dirty invalidations
Returns
the message for the specified index

Definition at line 206 of file RepeatedFieldBuilder.java.

◆ getMessageList()

List<MType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getMessageList ( )
inline

Gets a view of the builder as a list of messages. The returned list is live and will reflect any changes to the underlying builder.

Returns
the messages in the list

Definition at line 499 of file RepeatedFieldBuilder.java.

◆ getMessageOrBuilder()

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

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

Parameters
indexthe index of the message to get
Returns
the message or builder for the index as the base class interface

Definition at line 252 of file RepeatedFieldBuilder.java.

◆ getMessageOrBuilderList()

List<IType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.getMessageOrBuilderList ( )
inline

Gets a view of the builder as a list of MessageOrBuilders. This returned list is live and will reflect any changes to the underlying builder.

Returns
the builders in the list

Definition at line 525 of file RepeatedFieldBuilder.java.

◆ incrementModCounts()

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

Increments the mod counts so that an ConcurrentModificationException can be thrown if calling code tries to modify the builder while its iterating the list.

Definition at line 554 of file RepeatedFieldBuilder.java.

◆ isEmpty()

boolean com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.isEmpty ( )
inline

Gets whether the list is empty.

Returns
whether the list is empty

Definition at line 180 of file RepeatedFieldBuilder.java.

◆ markDirty()

void com.google.protobuf.RepeatedFieldBuilder< 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 546 of file RepeatedFieldBuilder.java.

◆ onChanged()

void com.google.protobuf.RepeatedFieldBuilder< 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 536 of file RepeatedFieldBuilder.java.

◆ remove()

void com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.remove ( int  index)
inline

Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.

Parameters
indexthe index at which to remove the message

Definition at line 416 of file RepeatedFieldBuilder.java.

◆ setMessage()

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

Sets a message at the specified index replacing the existing item at that index.

Parameters
indexthe index to set.
messagethe message to set
Returns
the builder

Definition at line 279 of file RepeatedFieldBuilder.java.

Member Data Documentation

◆ builders

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

Definition at line 79 of file RepeatedFieldBuilder.java.

◆ externalBuilderList

BuilderExternalList<MType, BType, IType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.externalBuilderList
private

Definition at line 109 of file RepeatedFieldBuilder.java.

◆ externalMessageList

MessageExternalList<MType, BType, IType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.externalMessageList
private

Definition at line 103 of file RepeatedFieldBuilder.java.

◆ externalMessageOrBuilderList

MessageOrBuilderExternalList<MType, BType, IType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.externalMessageOrBuilderList
private

Definition at line 116 of file RepeatedFieldBuilder.java.

◆ isClean

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

Definition at line 97 of file RepeatedFieldBuilder.java.

◆ isMessagesListMutable

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

Definition at line 75 of file RepeatedFieldBuilder.java.

◆ messages

List<MType> com.google.protobuf.RepeatedFieldBuilder< MType extends GeneratedMessage, BType extends GeneratedMessage.Builder, IType extends MessageOrBuilder >.messages
private

Definition at line 72 of file RepeatedFieldBuilder.java.

◆ parent

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

Definition at line 68 of file RepeatedFieldBuilder.java.


The documentation for this class was generated from the following file:
com.google.protobuf.RepeatedFieldBuilder.RepeatedFieldBuilder
RepeatedFieldBuilder(List< MType > messages, boolean isMessagesListMutable, GeneratedMessage.BuilderParent parent, boolean isClean)
Definition: RepeatedFieldBuilder.java:126
Builder
Definition: ruby/ext/google/protobuf_c/protobuf.h:162


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