Мы используем класс BaseEntity для объектов JPA, который реализует метод equals следующим образом.
@Override
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null) {
return false;
}
if (getClass() != object.getClass()) {
return false;
}
BaseEntity other = (BaseEntity) object;
if (this.getId() == null && other.getId() == null) {
return false;
}
if (this.getId() != other.getId() && (this.getId() == null || !this.id.equals(other.id))) {
return false;
}
return true;
}
Для всех классов, которые расширяет BaseEntity Sonar, появляется проблема с запахом кода.
Override the "equals" method in this class.
Как мы должны справиться с этим?