Reputation: 16233
Generating equals()
automatically in Eclipse is wonderful feature. However, it's still painful to generate it for a whole package. Is there anyway to generate it to a whole package?
Upvotes: 4
Views: 234
Reputation: 29438
I'm not sure there is any ways to apply Generate hashCode and equals
to whole package.
But there is a better way to open each of files and apply Generate hashCode and equals
.
Using lombok, you can add equals()
and hashCode()
by simply adding @EqualsAndHashCode
annotation for a class.
Generate hashCode and equals
in Eclipse is good feature, however, you have to maintain(regenerate) the generated code when you modify the class, especially when you added or removed the fields of class.
If you use lombok and @EqualsAndHashCode
, you don't have to regenerate the auto-generated methods. When you modified the class (add or remove fields) and save it (which means Eclipse compiles the modified files), lombok automatically regenerate the equals()
and hashCode()
methods.
Upvotes: 1