Re: [protobuf] Override equals and hashCode for generated Java code?

2019-03-07 Thread Dave Killian
When consumers use equals/hashcodes on the generated classes, new fields can never be added to the messages without breaking consumers at runtime. Adding new fields is typically how messages (and APIs in gRPC) are safely evolved over time. So having generated equals/hashcodes seems pretty

Re: [protobuf] Override equals and hashCode for generated Java code?

2018-02-28 Thread 'Feng Xiao' via Protocol Buffers
Protobuf generated classes can't be subclassed. I suggest create a wrapper type and implement the hashCode()/equals() there. To generate one .java file for each message, use "option java_multiple_files = true;" in your .proto file. On Wed, Feb 28, 2018 at 5:41 AM Kaushal Hooda

[protobuf] Override equals and hashCode for generated Java code?

2018-02-28 Thread Kaushal Hooda
Hi, The default behaviour for equals/hashCode is checking every single field for comparison/generating the hash. This is problematic for us - we need to override this to use only few fields (e.g., an ID field). Is there any way to do this, apart from editing the generated java code every time