google-code-export / protostuff

Automatically exported from code.google.com/p/protostuff
Apache License 2.0
1 stars 1 forks source link

meaningful equals and hashCode #144

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Is there a plan for a java_bean compiler option to build meaningful hashCode 
and equals methods?  This would be quite handy, and it's a feature I miss from 
the standard google implementation.

Original issue reported on code.google.com by justin.g...@ymail.com on 29 May 2013 at 9:22

GoogleCodeExporter commented 9 years ago
Not at the moment but you can certainly override java_bean by providing your 
own override_java_bean.stg that extends it.

The standard google impl hashes the descriptor as well as the field values.  In 
java land, only the field values are hashed.

Original comment by david.yu...@gmail.com on 30 May 2013 at 12:30

GoogleCodeExporter commented 9 years ago
I have an stg for this.  It seems to work well in my tests, but it will NOT 
work if you use the compiler option to generate primitive values.

Original comment by justin.g...@ymail.com on 5 Jun 2013 at 10:07

Attachments:

GoogleCodeExporter commented 9 years ago
I could not make a diff from these.  I'll review this and add the relevant 
parts as a generate_equals_hashcode option.

Thanks!

Original comment by david.yu...@gmail.com on 7 Jun 2013 at 3:30

GoogleCodeExporter commented 9 years ago
Implemented in version 1.3.2 (will be released soon).

Original comment by schepano...@gmail.com on 20 Feb 2015 at 5:37

GoogleCodeExporter commented 9 years ago
Out of curiosity, did you use the above changes (eq_java_bean.java.stg)?

It was a surprise to see any movement on this 18 months after posting!

Original comment by spicyl...@gmail.com on 23 Feb 2015 at 12:06