Thursday, September 3, 2009

Annotation driven equals, hashCode and toString

There is a good article online about annotation driven equals, hashCode and toString.  The benefit is that we don’t need repeat those very similar logic. It also give you a chance to maintain the contract “if two object equals, they should have the same hashCode”. We can implicitly add a field into “equals” method if it is involved in hashCode method.

No comments:

Post a Comment