Skip to content

Commit 523a5d4

Browse files
akoch-yattaHeikoKlare
authored andcommitted
Remove obsolete hashCode/equals for Region
This commit adapt the obsolete equals and hashCode methods for Region to use the super implementation instead. For the upcoming changes for win32 the current implementation cannot be used anymore because all handles will be created on demand. As the current implementation is equal in their behavior to the base behavior for these methods is inherited from Object.
1 parent f03d8f0 commit 523a5d4

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Region.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ void destroy() {
436436
*/
437437
@Override
438438
public boolean equals(Object object) {
439-
if (this == object) return true;
440-
if (!(object instanceof Region region)) return false;
441-
return handle == region.handle;
439+
return super.equals(object);
442440
}
443441

444442
/**
@@ -511,7 +509,7 @@ long regionToRects(long message, long rgn, long r, long path) {
511509
*/
512510
@Override
513511
public int hashCode() {
514-
return (int)handle;
512+
return super.hashCode();
515513
}
516514

517515
/**

bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/graphics/Region.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,7 @@ void destroy() {
310310
*/
311311
@Override
312312
public boolean equals(Object object) {
313-
if (this == object) return true;
314-
if (!(object instanceof Region)) return false;
315-
Region region = (Region)object;
316-
return handle == region.handle;
313+
return super.equals(object);
317314
}
318315

319316
/**
@@ -371,7 +368,7 @@ public static Region gtk_new(Device device, long handle) {
371368
*/
372369
@Override
373370
public int hashCode() {
374-
return (int)handle;
371+
return super.hashCode();
375372
}
376373

377374
/**

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,7 @@ void destroyHandlesExcept(Set<Integer> zoomLevels) {
253253
*/
254254
@Override
255255
public boolean equals (Object object) {
256-
if (this == object) return true;
257-
if (!(object instanceof Region)) return false;
258-
Region rgn = (Region)object;
259-
return getHandleForInitialZoom() == rgn.getHandleForInitialZoom();
256+
return super.equals(object);
260257
}
261258

262259
/**
@@ -295,7 +292,7 @@ Rectangle getBoundsInPixels() {
295292
*/
296293
@Override
297294
public int hashCode () {
298-
return (int)getHandleForInitialZoom();
295+
return super.hashCode();
299296
}
300297

301298
/**

0 commit comments

Comments
 (0)