Skip to content

Commit e288e18

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Implement equals() and hashCode() like a good little object." into jb-mr1-dev
2 parents 722565a + 9483891 commit e288e18

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)