I have a message Message defined in my .proto file. It has two fields, a required field and an optional field.
message Message
{
required int32 requiredField = 1;
optional int32 optionalField = 2;
}
Java code generated has its associated class Message and I am having two objects of it oMessage1 & oMessage2. oMessage1 is holding some value in its optionalField but oMessage2 is not holding any value in it (as its optional).
My Question is:
When I do oMessage1 = oMessage2, what happens to the value of optionalField of oMessage1?
- Does it vanishes? (Because
oMessage2doesn't have it) OR - Does it remain same? (Because
oMessage1have it and therefore assignment operator has taken care to not to overwrite it with non-existing fields)
I couldn't find its answer in documentation. And generated code was too big for me to analyse as I am relatively new to Java :( Ideally I am expecting #2 is an answer. But I like to verify with Protobuf experts so that I can take care about it in my code.
Many thanks in advance!