How can we put a variant message ( one of a few message types ) inside a protobuf message?
message typeA {
....
}
message typeB {
....
}
message ty
Check out the new oneof feature in version 2.6: https://developers.google.com/protocol-buffers/docs/reference/java-generated#oneof
You can now do something like this:
message TypeC {
oneof oneof_name {
TypeA a = 1;
TypeB b = 2;
}
}
Fields in the same oneof will share memory and only one field can be set at the same time.