invalidate leaderboard cache also upon RegattaLogEvents that are marked accordingly

Change-Id: Ib01741dd8a8854ce1f510e87ce5b30ee5bbcc937
This commit is contained in:
Axel Uhl
2019-10-25 10:02:29 +02:00
parent 2bc8c95685
commit 9df528476d
4 changed files with 16 additions and 4 deletions
@@ -23,7 +23,6 @@ public class RaceLogORCUseImpliedWindFromOtherRaceEventImpl extends AbstractLogE
super(createdAt, logicalTimePoint, author, pId);
this.raceLogEventData = new RaceLogEventDataImpl(/* involvedBoats */ null, passId);
this.otherRace = otherRace;
}
@Override
@@ -1,8 +1,10 @@
package com.sap.sailing.domain.abstractlog.race;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEvent;
/**
* Marker interface that all classes implementing {@link RaceLogEvent} should
* also implement, if the addition of that event should invalidate leaderboard cache.
* Marker interface that all classes implementing {@link RaceLogEvent} or {@link RegattaLogEvent} should also implement,
* if the addition of that event should invalidate leaderboard cache.
*
* @author Simon Marcel Pamies
*/
@@ -25,8 +25,10 @@ import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.sap.sailing.domain.abstractlog.AbstractLogEvent;
import com.sap.sailing.domain.abstractlog.race.InvalidatesLeaderboardCache;
import com.sap.sailing.domain.abstractlog.race.RaceLogEvent;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEvent;
import com.sap.sailing.domain.base.Boat;
import com.sap.sailing.domain.base.BoatClass;
import com.sap.sailing.domain.base.Competitor;
@@ -1181,7 +1183,15 @@ public abstract class AbstractLeaderboardWithCache implements Leaderboard {
return getCompetitorsFromBestToWorst(timePoint).indexOf(competitor) + 1;
}
public void raceLogEventAdded(RaceColumn raceColumn, RaceLogIdentifier raceLogIdentifier, RaceLogEvent event) {
protected void regattaLogEventAdded(RegattaLogEvent event) {
invalidateCacheIfEventSaysSo(event);
}
protected void raceLogEventAdded(RaceColumn raceColumn, RaceLogIdentifier raceLogIdentifier, RaceLogEvent event) {
invalidateCacheIfEventSaysSo(event);
}
private void invalidateCacheIfEventSaysSo(AbstractLogEvent<?> event) {
if (event instanceof InvalidatesLeaderboardCache) {
// make sure to invalidate the cache as this event indicates that
// it changes values the cache could still hold
@@ -932,6 +932,7 @@ public abstract class AbstractSimpleLeaderboardImpl extends AbstractLeaderboardW
@Override
public void regattaLogEventAdded(RegattaLogEvent event) {
getRaceColumnListeners().notifyListenersAboutRegattaLogEventAdded(event);
super.regattaLogEventAdded(event);
}
public String toString() {