locationtech / udig-platform

uDig parent project containing all core components. More plugins can be found in community repos: http://github.com/uDig-Community
http://udig.refractions.net
190 stars 133 forks source link

[HK][SONAR] using equals with hashCode #675

Open fgdrf opened 2 years ago

fgdrf commented 2 years ago

Change-Id: I15c03a9a0668e55b9f20492e1f2769a53d1ee182 Signed-off-by: Frank Gasdorf fgdrf@users.sourceforge.net

fgdrf commented 2 years ago

this fixed sonar finding that classes that override equals() also override hashCode().

fgdrf commented 2 years ago

@sschulz92 investigating if the bahavior of equals changed due to missing check of

        if (!(o instanceof AbstractRenderMetrics)) {
            return false;
        }

which has been replaced by

        if (getClass() != obj.getClass()) {
            return false;
        }

I guess I will add a test-case to verify ..

sschulz92 commented 2 years ago

You have changed a missing check? I do not get the point tbh :D

fgdrf commented 2 years ago

You have changed a missing check? I do not get the point tbh :D

Eclipse allows to generate equals & hashCode using members of the class. the generated equals method change as mentioned and I'd like to check if tow different instances / sub-classes of this Abstract class returned equal=true in the past while the new version would say (different class) that these are not equals anymore.

HTH