[#1380] Extract equals() and hashCode() generation into an overridable protected method.