Add duck typing equals check to TextBox

master
John 2022-06-08 19:03:06 -04:00
parent 0fbe9cf522
commit 7649f19215
1 changed files with 9 additions and 1 deletions

View File

@ -56,6 +56,14 @@ public class TextBox extends Rectangle {
@Override
public boolean equals(Object o) {
return this == o;
try {
TextBox t = (TextBox)o;
// duck typing equals check
// if it shows the same id, assume that it is equal; this is because ids should be unique
// also makes some corner cases easier
return this.id.equals(t.id);
} catch (ClassCastException e) {
return false;
}
}
}