This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Equals method generation, although giving the option to include "fields" from current class, should always (or maybe give the option) to check self equality. Also would be nice if it uses single return but that'll be another enhancement... #pseudocode public boolean equals(Object arg) { if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final T other = (T) obj; #proposal to include this: if (this != other) { #now folows the current functionality #foreach field included if (this.#field != other.#field && (this.#field == null || !this.#fieldequals(other.id))) { return false; } #end of new if included } return true; } }
The idea to include this behind comes for collections checking for equality of it's members, under a JPA aproach, most of times JPA Beans have an autogenerated ID, so they will remain "equaled" each other, since it's id field has not been generated yet but they're not the same object. class Order { private List<OrderLine> lines; public void addLine(OrderLine newLine) { if (!lines.contains(newLine) { //this should have equals improved, specually for unmanaged JPA entities lines.add(newLine); } } } There are also more cases where this will be a great enhacement, this is provided only as example.