|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.protobuf.RepeatedFieldBuilder<MType,BType,IType>
MType
- the type of message for the fieldBType
- the type of builder for the fieldIType
- the common interface for the message and the builderpublic class RepeatedFieldBuilder<MType extends GeneratedMessage,BType extends GeneratedMessage.Builder,IType extends MessageOrBuilder>
RepeatedFieldBuilder
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 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.
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 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 Summary | |
---|---|
RepeatedFieldBuilder(java.util.List<MType> messages,
boolean isMessagesListMutable,
GeneratedMessage.BuilderParent parent,
boolean isClean)
Constructs a new builder with an empty list of messages. |
Method Summary | |
---|---|
RepeatedFieldBuilder<MType,BType,IType> |
addAllMessages(java.lang.Iterable<? extends MType> 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. |
BType |
addBuilder(int index,
MType message)
Inserts a new builder at the specified position in this list. |
BType |
addBuilder(MType message)
Appends a new builder to the end of this list and returns the builder. |
RepeatedFieldBuilder<MType,BType,IType> |
addMessage(int index,
MType message)
Inserts the specified message at the specified position in this list. |
RepeatedFieldBuilder<MType,BType,IType> |
addMessage(MType message)
Appends the specified element to the end of this list. |
java.util.List<MType> |
build()
Builds the list of messages from the builder and returns them. |
void |
clear()
Removes all of the elements from this list. |
void |
dispose()
|
BType |
getBuilder(int index)
Gets a builder for the specified index. |
java.util.List<BType> |
getBuilderList()
Gets a view of the builder as a list of builders. |
int |
getCount()
Gets the count of items in the list. |
MType |
getMessage(int index)
Get the message at the specified index. |
java.util.List<MType> |
getMessageList()
Gets a view of the builder as a list of messages. |
IType |
getMessageOrBuilder(int index)
Gets the base class interface for the specified index. |
java.util.List<IType> |
getMessageOrBuilderList()
Gets a view of the builder as a list of MessageOrBuilders. |
boolean |
isEmpty()
Gets whether the list is empty. |
void |
markDirty()
A builder becomes dirty whenever a field is modified -- including fields in nested builders -- and becomes clean when build() is called. |
void |
remove(int index)
Removes the element at the specified position in this list. |
RepeatedFieldBuilder<MType,BType,IType> |
setMessage(int index,
MType message)
Sets a message at the specified index replacing the existing item at that index. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RepeatedFieldBuilder(java.util.List<MType> messages, boolean isMessagesListMutable, GeneratedMessage.BuilderParent parent, boolean isClean)
messages
- the current list of messagesisMessagesListMutable
- Whether the messages list is mutableparent
- a listener to notify of changesisClean
- whether the builder is initially marked cleanMethod Detail |
---|
public void dispose()
public int getCount()
public boolean isEmpty()
public MType getMessage(int index)
Builder
, it is converted to a Message
by
calling Message.Builder.buildPartial()
on it.
index
- the index of the message to get
public BType getBuilder(int index)
Message.toBuilder()
.
index
- the index of the message to get
public IType getMessageOrBuilder(int index)
index
- the index of the message to get
public RepeatedFieldBuilder<MType,BType,IType> setMessage(int index, MType message)
index
- the index to set.message
- the message to set
public RepeatedFieldBuilder<MType,BType,IType> addMessage(MType message)
message
- the message to add
public RepeatedFieldBuilder<MType,BType,IType> addMessage(int index, MType message)
index
- the index at which to insert the messagemessage
- the message to add
public RepeatedFieldBuilder<MType,BType,IType> addAllMessages(java.lang.Iterable<? extends MType> values)
values
- the messages to add
public BType addBuilder(MType message)
message
- the message to add which is the basis of the builder
public BType addBuilder(int index, MType message)
index
- the index at which to insert the buildermessage
- the message to add which is the basis of the builder
public void remove(int index)
index
- the index at which to remove the messagepublic void clear()
public java.util.List<MType> build()
public java.util.List<MType> getMessageList()
public java.util.List<BType> getBuilderList()
public java.util.List<IType> getMessageOrBuilderList()
public void markDirty()
GeneratedMessage.BuilderParent
markDirty
in interface GeneratedMessage.BuilderParent
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |