thank you
You suggest that this is the best way?
..Foo oldfoo = get_from_elsewhere();
..Baz newbaz = oldfoo.c1.toBuilder().set_f1(42).Build();
..Foo newfoo = oldfoo.toBuilder().set_c1(newbaz).Build();
..send_somewhere(newfoo);
i see this problematic if i have messages nested in messages
Il giorno lunedì 10 ottobre 2011 19:05:45 UTC+2, Ron ha scritto:
i believe this is where Foo.newBuilder(Foo oldFoo) comes into play. PB messages once built are immutable so instead you create a builder around an immutable Foo, change what you want through the builder's methods, then build a new (immutable) message using Builder.build().
there's also the method foo.toBuilder() which will do the same thing.