Add duck typing equals check to TextBox
parent
0fbe9cf522
commit
7649f19215
|
@ -56,6 +56,14 @@ public class TextBox extends Rectangle {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue