RepeatedFieldBuilderV3 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). Message.Builder to the repeated
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. SingleFieldBuilderV3 and RepeatedFieldBuilderV3 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.
| Modifier and Type | Class and Description |
|---|---|
| private static class | RepeatedFieldBuilderV3.BuilderExternalList<
the type of message for the field MType extends AbstractMessage, the type of builder for the field BType extends AbstractMessage.the common interface for the message and the builder IType extends MessageOrBuilder>Provides a live view of the builder as a list of builders. |
| private static class | RepeatedFieldBuilderV3.MessageExternalList<
the type of message for the field MType extends AbstractMessage, the type of builder for the field BType extends AbstractMessage.the common interface for the message and the builder IType extends MessageOrBuilder>Provides a live view of the builder as a list of messages. |
| private static class | RepeatedFieldBuilderV3.MessageOrBuilderExternalList<
the type of message for the field MType extends AbstractMessage, the type of builder for the field BType extends AbstractMessage.the common interface for the message and the builder IType extends MessageOrBuilder>Provides a live view of the builder as a list of builders. |
| Modifier and Type | Field and Description |
|---|---|
| private List | |
| private RepeatedFieldBuilderV3. | |
| private RepeatedFieldBuilderV3. | |
| private RepeatedFieldBuilderV3. | |
| private boolean | |
| private boolean | |
| private List | |
| private AbstractMessage. |
| Access | Constructor and Description |
|---|---|
| public | RepeatedFieldBuilderV3(List<MType>
the current list of messages messages, boolean Whether the messages list is mutable isMessagesListMutable, AbstractMessage.a listener to notify of changes parent,whether the builder is initially marked clean isClean)Constructs a new builder with an empty list of messages. |
| Modifier and Type | Method and Description |
|---|---|
| public RepeatedFieldBuilderV3 | Returns: the builderthe messages to add values)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. |
| public BType | Returns: the new builderthe message to add which is the basis of the builder message)Appends a new builder to the end of this list and returns the builder. |
| public BType | Returns: the builderthe index at which to insert the builder index, MType the message to add which is the basis of the builder message)Inserts a new builder at the specified position in this list. |
| public RepeatedFieldBuilderV3 | Returns: the builderthe message to add message)Appends the specified element to the end of this list. |
| public RepeatedFieldBuilderV3 | Returns: the builderthe index at which to insert the message index, MType the message to add message)Inserts the specified message at the specified position in this list. |
| public List | Returns: an immutable list of messagesBuilds the list of messages from the builder and returns them. |
| public void | |
| public void | |
| private void | |
| private void | |
| public BType | Returns: The builder for that indexthe index of the message to get index)Gets a builder for the specified index. |
| public List | |
| public int | |
| public MType | Returns: the message for the specified indexthe index of the message to get index)Get the message at the specified index. |
| private MType | Returns: the message for the specified indexthe index of the message to get index, boolean this is being called for build so we want to make sure we
SingleFieldBuilderV3.build to send dirty invalidations forBuild)Get the message at the specified index. |
| public List | |
| public IType | Returns: the message or builder for the index as the base class interfacethe index of the message to get index)Gets the base class interface for the specified index. |
| public List | Returns: the builders in the listGets a view of the builder as a list of MessageOrBuilders. |
| private void | incrementModCounts()
Increments the mod counts so that an ConcurrentModificationException can be thrown if calling code tries to modify the builder while its iterating the list. |
| public boolean | |
| public void | markDirty()
Implements com. |
| private void | onChanged()
Called when a the builder or one of its nested children has changed and any parent should be notified of its invalidation. |
| public void | remove(int
the index at which to remove the message index)Removes the element at the specified position in this list. |
| public RepeatedFieldBuilderV3 | Returns: the builderthe index to set. index, MType the message to set message)Sets a message at the specified index replacing the existing item at that index. |
| builders | back to summary |
|---|---|
| private List<SingleFieldBuilderV3<MType, BType, IType>> builders | |
| externalBuilderList | back to summary |
|---|---|
| private RepeatedFieldBuilderV3. | |
| externalMessageList | back to summary |
|---|---|
| private RepeatedFieldBuilderV3. | |
| externalMessageOrBuilderList | back to summary |
|---|---|
| private RepeatedFieldBuilderV3. | |
| isClean | back to summary |
|---|---|
| private boolean isClean | |
| isMessagesListMutable | back to summary |
|---|---|
| private boolean isMessagesListMutable | |
| messages | back to summary |
|---|---|
| private List<MType> messages | |
| parent | back to summary |
|---|---|
| private AbstractMessage. | |
| RepeatedFieldBuilderV3 | back to summary |
|---|---|
| public RepeatedFieldBuilderV3(List<MType> messages, boolean isMessagesListMutable, AbstractMessage. Constructs a new builder with an empty list of messages.
| |
| addAllMessages | back to summary |
|---|---|
| public RepeatedFieldBuilderV3 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.
| |
| addBuilder | back to summary |
|---|---|
| public BType addBuilder(MType message) Appends a new builder to the end of this list and returns the builder.
| |
| addBuilder | back to summary |
|---|---|
| public BType addBuilder(int index, MType message) 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).
| |
| addMessage | back to summary |
|---|---|
| public RepeatedFieldBuilderV3 Appends the specified element to the end of this list.
| |
| addMessage | back to summary |
|---|---|
| public RepeatedFieldBuilderV3 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).
| |
| build | back to summary |
|---|---|
| public List Builds the list of messages from the builder and returns them.
| |
| clear | back to summary |
|---|---|
| public void clear() Removes all of the elements from this list. The list will be empty after this call returns. | |
| dispose | back to summary |
|---|---|
| public void dispose() | |
| ensureBuilders | back to summary |
|---|---|
| private void ensureBuilders() 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. | |
| ensureMutableMessageList | back to summary |
|---|---|
| private void ensureMutableMessageList() Ensures that the list of messages is mutable so it can be updated. If it's immutable, a copy is made. | |
| getBuilder | back to summary |
|---|---|
| public BType getBuilder(int index) Gets a builder for the specified index. If no builder has been created for that index, a
builder is created on demand by calling
| |
| getBuilderList | back to summary |
|---|---|
| public List 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.
| |
| getCount | back to summary |
|---|---|
| public int getCount() Gets the count of items in the list.
| |
| getMessage | back to summary |
|---|---|
| public MType getMessage(int index) Get the message at the specified index. If the message is currently stored as a
| |
| getMessage | back to summary |
|---|---|
| private MType getMessage(int index, boolean forBuild) Get the message at the specified index. If the message is currently stored as a
| |
| getMessageList | back to summary |
|---|---|
| public List 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.
| |
| getMessageOrBuilder | back to summary |
|---|---|
| public IType getMessageOrBuilder(int index) 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.
| |
| getMessageOrBuilderList | back to summary |
|---|---|
| public List 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.
| |
| incrementModCounts | back to summary |
|---|---|
| private void incrementModCounts() Increments the mod counts so that an ConcurrentModificationException can be thrown if calling code tries to modify the builder while its iterating the list. | |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Gets whether the list is empty.
| |
| markDirty | back to summary |
|---|---|
| public void markDirty() Implements com. Doc from com. 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.
| |
| onChanged | back to summary |
|---|---|
| private void onChanged() Called when a the builder or one of its nested children has changed and any parent should be notified of its invalidation. | |
| remove | back to summary |
|---|---|
| public void remove(int index) 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.
| |
| setMessage | back to summary |
|---|---|
| public RepeatedFieldBuilderV3 Sets a message at the specified index replacing the existing item at that index.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv RepeatedFieldBuilderV3 |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public BType | get(int
index of the element to return index)Implements abstract java. Implements java. |
| pack-priv void | |
| public int | size()
Implements abstract java. Implements java. |
| builder | back to summary |
|---|---|
| pack-priv RepeatedFieldBuilderV3<MType, BType, IType> builder | |
| BuilderExternalList | back to summary |
|---|---|
| pack-priv BuilderExternalList(RepeatedFieldBuilderV3<MType, BType, IType> builder) | |
| get | back to summary |
|---|---|
| public BType get(int index) Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| incrementModCount | back to summary |
|---|---|
| pack-priv void incrementModCount() | |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv RepeatedFieldBuilderV3 |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public MType | get(int
index of the element to return index)Implements abstract java. Implements java. |
| pack-priv void | |
| public int | size()
Implements abstract java. Implements java. |
| builder | back to summary |
|---|---|
| pack-priv RepeatedFieldBuilderV3<MType, BType, IType> builder | |
| MessageExternalList | back to summary |
|---|---|
| pack-priv MessageExternalList(RepeatedFieldBuilderV3<MType, BType, IType> builder) | |
| get | back to summary |
|---|---|
| public MType get(int index) Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| incrementModCount | back to summary |
|---|---|
| pack-priv void incrementModCount() | |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv RepeatedFieldBuilderV3 |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public IType | get(int
index of the element to return index)Implements abstract java. Implements java. |
| pack-priv void | |
| public int | size()
Implements abstract java. Implements java. |
| builder | back to summary |
|---|---|
| pack-priv RepeatedFieldBuilderV3<MType, BType, IType> builder | |
| MessageOrBuilderExternalList | back to summary |
|---|---|
| pack-priv MessageOrBuilderExternalList(RepeatedFieldBuilderV3<MType, BType, IType> builder) | |
| get | back to summary |
|---|---|
| public IType get(int index) Implements abstract java. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| incrementModCount | back to summary |
|---|---|
| pack-priv void incrementModCount() | |
| size | back to summary |
|---|---|
| public int size() Implements abstract java. Implements java. Doc from java. Returns the number of elements in this list. If this list contains
more than
| |