mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-17 01:31:01 +00:00
CompetitorDTO equality now considers changeable properties in addition to ID; dynamic, incremental leaderboard update now works with competitor changes
This commit is contained in:
1 parent
1806926058
commit
b92545d3da
2 files changed
+61
-6
No files matched your search
+33
-6
@@ -2,6 +2,15 @@ package com.sap.sailing.domain.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Equality and hash code are based on the {@link #getIdAsString() ID}, the {@link #getSailID() sail number}, the
|
||||
* {@link #getBoatClass() boat class} (whose equality and hash code, in turn, depends on its name) and the
|
||||
* {@link #getThreeLetterIocCountryCode() IOC country code}. Note that the three latter properties are subject
|
||||
* to change for a competitor while the ID remains unchanged.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class CompetitorDTOImpl extends NamedDTO implements CompetitorDTO, Serializable {
|
||||
private static final long serialVersionUID = -4997852354821083154L;
|
||||
private String twoLetterIsoCountryCode;
|
||||
@@ -27,8 +36,11 @@ public class CompetitorDTOImpl extends NamedDTO implements CompetitorDTO, Serial
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * getIdAsString().hashCode();
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((boatClass == null) ? 0 : boatClass.hashCode());
|
||||
result = prime * result + ((idAsString == null) ? 0 : idAsString.hashCode());
|
||||
result = prime * result + ((sailID == null) ? 0 : sailID.hashCode());
|
||||
result = prime * result + ((threeLetterIocCountryCode == null) ? 0 : threeLetterIocCountryCode.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -36,15 +48,30 @@ public class CompetitorDTOImpl extends NamedDTO implements CompetitorDTO, Serial
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CompetitorDTOImpl other = (CompetitorDTOImpl) obj;
|
||||
if (getIdAsString() == null) {
|
||||
if (other.getIdAsString() != null)
|
||||
if (boatClass == null) {
|
||||
if (other.boatClass != null)
|
||||
return false;
|
||||
} else if (!getIdAsString().equals(other.getIdAsString()))
|
||||
} else if (!boatClass.equals(other.boatClass))
|
||||
return false;
|
||||
if (idAsString == null) {
|
||||
if (other.idAsString != null)
|
||||
return false;
|
||||
} else if (!idAsString.equals(other.idAsString))
|
||||
return false;
|
||||
if (sailID == null) {
|
||||
if (other.sailID != null)
|
||||
return false;
|
||||
} else if (!sailID.equals(other.sailID))
|
||||
return false;
|
||||
if (threeLetterIocCountryCode == null) {
|
||||
if (other.threeLetterIocCountryCode != null)
|
||||
return false;
|
||||
} else if (!threeLetterIocCountryCode.equals(other.threeLetterIocCountryCode))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
+28
@@ -1,5 +1,11 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
/**
|
||||
* Equality and hash code are based on the index pointing into a previous leaderboard's competitors list.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class PreviousCompetitorDTOImpl implements CompetitorDTO {
|
||||
private static final long serialVersionUID = 8820028699103040805L;
|
||||
private int indexInPreviousCompetitorList;
|
||||
@@ -14,6 +20,28 @@ public class PreviousCompetitorDTOImpl implements CompetitorDTO {
|
||||
protected int getIndexInPreviousCompetitorList() {
|
||||
return indexInPreviousCompetitorList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + indexInPreviousCompetitorList;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
PreviousCompetitorDTOImpl other = (PreviousCompetitorDTOImpl) obj;
|
||||
if (indexInPreviousCompetitorList != other.indexInPreviousCompetitorList)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTwoLetterIsoCountryCode() {
|
||||
|
||||
Reference in new issue
Block a user