forked from j62/ctbrec
1
0
Fork 0

Change equals and hashcode in Recording to only use the ID

This commit is contained in:
0xb00bface 2020-10-17 13:37:49 +02:00
parent fcbe4a2e25
commit e49ef57f21
1 changed files with 5 additions and 20 deletions

View File

@ -222,9 +222,7 @@ public class Recording implements Serializable {
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getStartDate() == null) ? 0 : (int) (getStartDate().toEpochMilli() ^ (getStartDate().toEpochMilli() >>> 32)));
result = prime * result + ((model == null) ? 0 : model.hashCode());
result = prime * result + ((getAbsoluteFile() == null) ? 0 : getAbsoluteFile().hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@ -234,27 +232,14 @@ public class Recording implements Serializable {
return true;
if (obj == null)
return false;
if(!(obj instanceof Recording)) {
if (getClass() != obj.getClass())
return false;
}
Recording other = (Recording) obj;
if (getModel() == null) {
if (other.getModel() != null) {
if (id == null) {
if (other.id != null)
return false;
}
} else if (!getModel().equals(other.getModel())) {
} else if (!id.equals(other.id))
return false;
}
if (!getAbsoluteFile().equals(other.getAbsoluteFile())) {
return false;
}
if (getStartDate() == null) {
if (other.getStartDate() != null) {
return false;
}
} else if (getStartDate().toEpochMilli() != other.getStartDate().toEpochMilli()) {
return false;
}
return true;
}