Skip to content

Commit 9483891

Browse files
author
Jeff Brown
committed
Implement equals() and hashCode() like a good little object.
Change-Id: I06fc8f96586c72095ffa142d52fbd71af05cee97
1 parent df693de commit 9483891

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/java/android/os/WorkSource.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ public void clear() {
7676
mNum = 0;
7777
}
7878

79+
@Override
80+
public boolean equals(Object o) {
81+
return o instanceof WorkSource && !diff((WorkSource)o);
82+
}
83+
84+
@Override
85+
public int hashCode() {
86+
int result = 0;
87+
for (int i = 0; i < mNum; i++) {
88+
result = ((result << 4) | (result >>> 28)) ^ mUids[i];
89+
}
90+
return result;
91+
}
92+
7993
/**
8094
* Compare this WorkSource with another.
8195
* @param other The WorkSource to compare against.

0 commit comments

Comments
 (0)