am using MessageDifferencer API to compute difference between two Google Protobuf messages. I passed the below two messages to the API.
name: "MSG1" cfgMsg { cfgName: "obj1" msgId: 100 cfgObj { uuid: "obj1_1" node_id: "1.1.1.1" intf_id: 100 } cfgObj { uuid: "obj1_2" node_id: "2.2.2.2" intf_id: 200 } cfgObj { uuid: "obj1_3" node_id: "3.3.3.3" intf_id: 300 } } | name: "MSG2" cfgMsg { cfgName: "obj2" msgId: 200 cfgObj { uuid: "obj1_1" node_id: "1.1.1.1" intf_id: 100 } cfgObj { uuid: "obj1_2" node_id: "4.4.4.4" intf_id: 200 } cfgObj { uuid: "obj1_3" node_id: "3.3.3.3" intf_id: 300 } cfgObj { uuid: "obj1_5" router_id: "5.5.5.5" intf_id: 500 } |
Output from the Message Differencer API is as below.
```
Message Differences:
modified: name: "MSG1" -> "MSG2"
modified: cfgMsg.cfgName: "obj1" -> "obj2"
modified: cfgMsg.msgId: 100 -> 200
modified: cfgMsg.cfgObj[1].node_id: "2.2.2.2" -> "4.4.4.4"
added: cfgMsg.cfgObj[3]: { uuid: "obj1_5" node_id: "5.5.5.5" intf_id: 500 }
```
My question about this API is: Why does the output is in this format ? It is not really in any usable format for anyone who is calling this API. The calling application has to literally do a string parse to make sense of this output and conclude anything from the returned output. Also, this output will change depending on how the original message was defined so getting this parsing in a right way is pretty complex. In fact, even after parsing it is difficult to match with original message type with either FieldDescriptor, Reflection or Descriptor. Ideally, returning a new object of original message type with changed values would make more sense to me.
Do I understand this API correctly or Am I interpreting the above API usage in a wrong way ? I don't know if this should be used in conjunction with any other API to make sense ?
It will be really helpful for me and I really appreciate if any expect on this group could explain few details around this ?
Thanks,
Kiran