If I have a root object of a deep tree of objects (I'm using Java), and I 
call toBuilder() on it, so that I can manipulate it, do its "subobjects" 
"become" builders as well?

That is, if I do:

Top.Builder topBuilder = top.toBuilder();

...and then later I do:

SubObject.Builder subObjectBuilder = topBuilder.getSubObjectBuilder();

...will that subObjectBuilder be populated with the same state as 
top.getSubObject()?  And, if I use the subObjectBuilder and do mutating 
things with it, when I (finally) call topBuilder.build(), will the changes 
made via the subObjectBuilder "persist"?  Or must I manually call 
subObjectBuilder.build(), and 
topBuilder.setSubObject(resultOfSubObjectBuilderBuildCall)?  (I assume the 
build() call from topBuilder will be "propagated" "down" through the 

To ask the question in a slightly different way in case this sheds light, 
if I know that I'm going to be passing a tree of these messages around, and 
I know that I might modify certain parts of the tree, would it make sense 
to begin by calling toBuilder() on the top object first, and then writing 
my manipulation methods to accept builders of various kinds, rather than 
the immutable objects they work with?

Thanks for any help and time,

You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to