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 
problematic.  Perhaps hashcodes/equals should fail, or should at least be 
configurable on the proto definition so that we can generate code that 
prevents consumers from relying on this.  

On Wednesday, February 28, 2018 at 4:53:03 PM UTC-8, Feng Xiao wrote:
>
> 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 <hoodak...@gmail.com 
> <javascript:>> wrote:
>
>> 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 I run protoc?
>>
>> Also, is it possible to generate one .java file for each message type, 
>> instead of having them all inside one huge file for the entire schema?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Protocol Buffers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to protobuf+u...@googlegroups.com <javascript:>.
>> To post to this group, send email to prot...@googlegroups.com 
>> <javascript:>.
>> Visit this group at https://groups.google.com/group/protobuf.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to protobuf+unsubscr...@googlegroups.com.
To post to this group, send email to protobuf@googlegroups.com.
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to