This question is best to be asked in
protobuf's thread.
To switch between setting data A or B in message C, you just use setters for A or B from message C's builder. That last call wins. (FWIW, internally calling the setter for fields in oneof data sets a specifier pointing to it. When you use a getter to read fields in oneof data, the getter always checks the specifier first and only return your value if the specifier points to that field. Otherwise, default value is returned (remember, every field has a default value)).
You cannot set both A and B. Even if you set both of them on the server side, only the one you set lastly will be transmitted to the client side and the client can only read that field's value. This is the semantics of oneof, if you have use case of setting both, don't use oneof, just flatten fields in the message.