hashCode
and equals
generation using the Java 7 Objects
class has now been implemented in Eclipse. I was working on the feature request 424214 back in August 2018 and my contributions were merged in the JDT UI codebase shortly afterwards (see commit f543cd6).
Here’s an overview of the new option in the Source > Generate hashCode() and equals… tool:
This has been officially released in Eclipse 4.9 in September 2018. Simply download the latest version of Eclipse (downloads can be found here), or install the latest available software with the following update site:
http://download.eclipse.org/releases/latest
In addition to this new feature, arrays are now handled more cleverly. The generation will use the Arrays.deepHashCode
and Arrays.deepEquals
methods in a number of cases where it would previously incorrectly prefer the standard Arrays.hashCode
and Arrays.equals
alternatives.