I want to merge two complex proto objects protoA and protoB of the same type, where if a field is set in both the objects, the value of protoB should be set in the resulting proto.
I could use the .mergeFrom() function:
protoA.toBuilder().mergeFrom(protoB).build()
but according to the docs, repeated fields will be concatenated.
mergeFrom(Message other): (builder only) merges the contents of other into this message, overwriting singular scalar fields, merging composite fields, and concatenating repeated fields.
I don't want this behaviour. Is there a elegant way to do this than to manually set each repeated fields?