Add null check to Task#equals()

Adds a couple base conditions to Task#equals -- essentially so that if the comparison target is null, returns false.

In Java Platform SE 8 docs, Object#equals() implements "For any non-null reference value x, x.equals(null) should return false. Since Task#equals() overrides Object.equals(), we should implement this too.

Bug: 274835596
Test: Manual
Change-Id: If8e23f620c4f2c88d1e058325fdebc54022acf3b
This commit is contained in:
Jeremy Sim
2023-08-01 14:14:43 -07:00
parent ac8018752c
commit e91d888272

View File

@@ -336,6 +336,14 @@ public class Task {
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof Task)) {
return false;
}
// Check that the id matches
Task t = (Task) o;
return key.equals(t.key);