Implement hashCode() when you implement equals()!

This commit is contained in:
cpfeiffer 2017-02-10 00:32:03 +01:00
parent f35e3e460d
commit 89bf63d540
1 changed files with 11 additions and 0 deletions

View File

@ -43,4 +43,15 @@ public class MusicStateSpec {
this.shuffle == stateSpec.shuffle &&
this.repeat == stateSpec.repeat;
}
@Override
public int hashCode() {
int result = (int) state;
// ignore the position -- it is taken into account in equals()
// result = 31 * result + position;
result = 31 * result + playRate;
result = 31 * result + (int) shuffle;
result = 31 * result + (int) repeat;
return result;
}
}