The latest issue of the JavaSpecialists newsletter (by Dr. Heinz Kabutz) features a lengthy look at possibility of applying the Strategy design pattern to the equals() and hashCode() methods commonly used in Java. In it he concludes that the equals and hashCode methods autogenerated by IntelliJ Idea are better from a performance standpoint.
If your IDE of choice doesn’t include the ability to autogenerate the bodies of the above mentioned methods, you might also check out the EqualsBuilder, HashCodeBuilder and ToStringBuilder classes in the Jakarta Commons Lang library.
Just be aware of performance impact of those helper classes. In our tests we observed anywhere from 30 to up to 200% slowdown in certain operations, especially when working with Collections, sorting etc.
More info can be found here:
http://www.jroller.com/page/eu/20050415#to_commons_or_not_to
http://www.jroller.com/page/maximdim/20050418#how_bad_are_commons_lang