mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
refs bug 1395
# unified RaceLogAnalyzer interface to reduce huge amount of duplicated code
This commit is contained in:
1 parent
5f5ff9234c
commit
3f3e7b142b
32 files changed
+181
-322
No files matched your search
+3
@@ -17,6 +17,9 @@ import com.sap.sailing.domain.tracking.Track;
|
||||
* </p>
|
||||
*/
|
||||
public interface RaceLog extends Track<RaceLogEvent>, WithID {
|
||||
|
||||
public static final int DefaultPassId = 0;
|
||||
|
||||
/**
|
||||
* Gets the current pass id.
|
||||
*
|
||||
|
||||
+5
-18
@@ -5,30 +5,17 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
|
||||
public class AbortingFlagFinder extends RaceLogAnalyzer {
|
||||
public class AbortingFlagFinder extends RaceLogAnalyzer<RaceLogFlagEvent> {
|
||||
|
||||
public AbortingFlagFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public RaceLogFlagEvent getAbortingFlagEvent() {
|
||||
|
||||
@Override
|
||||
protected RaceLogFlagEvent performAnalyzation() {
|
||||
RaceLogFlagEvent newFlagEvent = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
newFlagEvent = searchForAbortingFlagEvent();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return newFlagEvent;
|
||||
}
|
||||
|
||||
private RaceLogFlagEvent searchForAbortingFlagEvent() {
|
||||
RaceLogFlagEvent newFlagEvent = null;
|
||||
|
||||
if (raceLog.getCurrentPassId() > 0) {
|
||||
if (raceLog.getCurrentPassId() > RaceLog.DefaultPassId) {
|
||||
int relevantPassId = raceLog.getCurrentPassId() - 1;
|
||||
for (RaceLogEvent event : getAllEvents()) {
|
||||
if (event.getPassId() == relevantPassId) {
|
||||
@@ -45,7 +32,7 @@ public class AbortingFlagFinder extends RaceLogAnalyzer {
|
||||
return newFlagEvent;
|
||||
}
|
||||
|
||||
private boolean isAbortingFlag(RaceLogFlagEvent flagEvent) {
|
||||
private static boolean isAbortingFlag(RaceLogFlagEvent flagEvent) {
|
||||
return (flagEvent.getUpperFlag().equals(Flags.AP) && flagEvent.isDisplayed())
|
||||
|| (flagEvent.getUpperFlag().equals(Flags.NOVEMBER) && flagEvent.isDisplayed())
|
||||
|| (flagEvent.getUpperFlag().equals(Flags.FIRSTSUBSTITUTE) && flagEvent.isDisplayed());
|
||||
|
||||
+3
-15
@@ -9,26 +9,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFinishPositioningConfirmedEvent;
|
||||
|
||||
public class ConfirmedFinishPositioningListFinder extends RaceLogAnalyzer {
|
||||
public class ConfirmedFinishPositioningListFinder extends RaceLogAnalyzer<List<Triple<Serializable, String, MaxPointsReason>>> {
|
||||
|
||||
public ConfirmedFinishPositioningListFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public List<Triple<Serializable, String, MaxPointsReason>> getFinishPositioningList() {
|
||||
List<Triple<Serializable, String, MaxPointsReason>> lastFinishPositioningList = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
lastFinishPositioningList = searchForLastFinishPositioningList();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return lastFinishPositioningList;
|
||||
}
|
||||
|
||||
private List<Triple<Serializable, String, MaxPointsReason>> searchForLastFinishPositioningList() {
|
||||
@Override
|
||||
protected List<Triple<Serializable, String, MaxPointsReason>> performAnalyzation() {
|
||||
List<Triple<Serializable, String, MaxPointsReason>> lastFinishPositioningList = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
|
||||
+3
-15
@@ -9,26 +9,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFinishPositioningListChangedEvent;
|
||||
|
||||
public class FinishPositioningListFinder extends RaceLogAnalyzer {
|
||||
public class FinishPositioningListFinder extends RaceLogAnalyzer<List<Triple<Serializable, String, MaxPointsReason>>> {
|
||||
|
||||
public FinishPositioningListFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public List<Triple<Serializable, String, MaxPointsReason>> getFinishPositioningList() {
|
||||
List<Triple<Serializable, String, MaxPointsReason>> lastFinishPositioningList = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
lastFinishPositioningList = searchForLastFinishPositioningList();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return lastFinishPositioningList;
|
||||
}
|
||||
|
||||
private List<Triple<Serializable, String, MaxPointsReason>> searchForLastFinishPositioningList() {
|
||||
@Override
|
||||
protected List<Triple<Serializable, String, MaxPointsReason>> performAnalyzation() {
|
||||
List<Triple<Serializable, String, MaxPointsReason>> lastFinishPositioningList = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
|
||||
+3
-15
@@ -6,26 +6,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogRaceStatusEvent;
|
||||
|
||||
public class FinishedTimeFinder extends RaceLogAnalyzer {
|
||||
public class FinishedTimeFinder extends RaceLogAnalyzer<TimePoint> {
|
||||
|
||||
public FinishedTimeFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public TimePoint getFinishedTime() {
|
||||
TimePoint finishedTime = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
finishedTime = searchForFinishedTime();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return finishedTime;
|
||||
}
|
||||
|
||||
private TimePoint searchForFinishedTime() {
|
||||
@Override
|
||||
protected TimePoint performAnalyzation() {
|
||||
TimePoint finishedTime = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
|
||||
+3
-15
@@ -6,26 +6,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogRaceStatusEvent;
|
||||
|
||||
public class FinishingTimeFinder extends RaceLogAnalyzer {
|
||||
public class FinishingTimeFinder extends RaceLogAnalyzer<TimePoint> {
|
||||
|
||||
public FinishingTimeFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public TimePoint getFinishingTime() {
|
||||
TimePoint finishingTime = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
finishingTime = searchForFinishingTime();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return finishingTime;
|
||||
}
|
||||
|
||||
private TimePoint searchForFinishingTime() {
|
||||
@Override
|
||||
protected TimePoint performAnalyzation() {
|
||||
TimePoint finishingTime = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
|
||||
+3
-14
@@ -4,25 +4,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogGateLineOpeningTimeEvent;
|
||||
|
||||
public class GateLineOpeningTimeFinder extends RaceLogAnalyzer {
|
||||
public class GateLineOpeningTimeFinder extends RaceLogAnalyzer<Long> {
|
||||
|
||||
public GateLineOpeningTimeFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public Long getGateLineOpeningTime() {
|
||||
Long gateLineOpeningTime;
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
gateLineOpeningTime = searchForGateLineOpeningTime();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return gateLineOpeningTime;
|
||||
}
|
||||
|
||||
private Long searchForGateLineOpeningTime() {
|
||||
@Override
|
||||
protected Long performAnalyzation() {
|
||||
Long gateLineOpeningTime = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.sap.sailing.domain.racelog.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
|
||||
public class IndividualRecallDisplayedFinder extends IndividualRecallFinder {
|
||||
|
||||
public IndividualRecallDisplayedFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
protected boolean isRelevant(RaceLogFlagEvent flagEvent) {
|
||||
return flagEvent.getUpperFlag().equals(Flags.XRAY) && flagEvent.isDisplayed();
|
||||
}
|
||||
|
||||
}
|
||||
+6
-46
@@ -1,50 +1,26 @@
|
||||
package com.sap.sailing.domain.racelog.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
|
||||
public class IndividualRecallFinder extends RaceLogAnalyzer {
|
||||
public abstract class IndividualRecallFinder extends RaceLogAnalyzer<TimePoint> {
|
||||
|
||||
public IndividualRecallFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public TimePoint getIndividualRecallDisplayedTime() {
|
||||
TimePoint displayedTime = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
displayedTime = searchForIndividualRecallDisplayedTime();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return displayedTime;
|
||||
}
|
||||
|
||||
public TimePoint getIndividualRecallDisplayedRemovalTime() {
|
||||
TimePoint removalTime = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
removalTime = searchForIndividualRecallRemovalTime();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return removalTime;
|
||||
}
|
||||
|
||||
private TimePoint searchForIndividualRecallDisplayedTime() {
|
||||
protected abstract boolean isRelevant(RaceLogFlagEvent flagEvent);
|
||||
|
||||
@Override
|
||||
protected TimePoint performAnalyzation() {
|
||||
TimePoint displayedTime = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
if (event instanceof RaceLogFlagEvent) {
|
||||
RaceLogFlagEvent flagEvent = (RaceLogFlagEvent) event;
|
||||
if (flagEvent.getUpperFlag().equals(Flags.XRAY) && flagEvent.isDisplayed()) {
|
||||
if (isRelevant(flagEvent)) {
|
||||
displayedTime = flagEvent.getTimePoint();
|
||||
}
|
||||
}
|
||||
@@ -52,21 +28,5 @@ public class IndividualRecallFinder extends RaceLogAnalyzer {
|
||||
|
||||
return displayedTime;
|
||||
}
|
||||
|
||||
private TimePoint searchForIndividualRecallRemovalTime() {
|
||||
TimePoint removalTime = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
if (event instanceof RaceLogFlagEvent) {
|
||||
RaceLogFlagEvent flagEvent = (RaceLogFlagEvent) event;
|
||||
if (flagEvent.getUpperFlag().equals(Flags.XRAY) && !flagEvent.isDisplayed()) {
|
||||
removalTime = flagEvent.getTimePoint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return removalTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.sap.sailing.domain.racelog.analyzing.impl;
|
||||
|
||||
import com.sap.sailing.domain.common.racelog.Flags;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
|
||||
public class IndividualRecallRemovedFinder extends IndividualRecallFinder {
|
||||
|
||||
public IndividualRecallRemovedFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
protected boolean isRelevant(RaceLogFlagEvent flagEvent) {
|
||||
return flagEvent.getUpperFlag().equals(Flags.XRAY) && !flagEvent.isDisplayed();
|
||||
}
|
||||
|
||||
}
|
||||
+3
-15
@@ -4,26 +4,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogFlagEvent;
|
||||
|
||||
public class LastFlagFinder extends RaceLogAnalyzer {
|
||||
public class LastFlagFinder extends RaceLogAnalyzer<RaceLogFlagEvent> {
|
||||
|
||||
public LastFlagFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public RaceLogFlagEvent getLastFlagEvent() {
|
||||
RaceLogFlagEvent lastFlagEvent = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
lastFlagEvent = searchForLastFlagEvent();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return lastFlagEvent;
|
||||
}
|
||||
|
||||
private RaceLogFlagEvent searchForLastFlagEvent() {
|
||||
@Override
|
||||
protected RaceLogFlagEvent performAnalyzation() {
|
||||
for (RaceLogEvent event : getPassEventsDescending()) {
|
||||
if (event instanceof RaceLogFlagEvent) {
|
||||
return (RaceLogFlagEvent) event;
|
||||
|
||||
+3
-15
@@ -6,26 +6,14 @@ import com.sap.sailing.domain.racelog.RaceLogCourseDesignChangedEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.analyzing.impl.RaceLogAnalyzer;
|
||||
|
||||
public class LastPublishedCourseDesignFinder extends RaceLogAnalyzer {
|
||||
public class LastPublishedCourseDesignFinder extends RaceLogAnalyzer<CourseBase> {
|
||||
|
||||
public LastPublishedCourseDesignFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public CourseBase getLastCourseDesign() {
|
||||
CourseBase lastCourseData = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
lastCourseData = searchForLastCourseData();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return lastCourseData;
|
||||
}
|
||||
|
||||
private CourseBase searchForLastCourseData() {
|
||||
@Override
|
||||
protected CourseBase performAnalyzation() {
|
||||
CourseBase lastCourseData = null;
|
||||
|
||||
for (RaceLogEvent event : getAllEvents()) {
|
||||
|
||||
+3
-13
@@ -4,24 +4,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogPathfinderEvent;
|
||||
|
||||
public class PathfinderFinder extends RaceLogAnalyzer {
|
||||
public class PathfinderFinder extends RaceLogAnalyzer<String> {
|
||||
|
||||
public PathfinderFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public String getPathfinderId() {
|
||||
String pathfinderId;
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
pathfinderId = searchForPathfinderId();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
return pathfinderId;
|
||||
}
|
||||
|
||||
private String searchForPathfinderId() {
|
||||
@Override
|
||||
protected String performAnalyzation() {
|
||||
String pathfinderId = null;
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
if (event instanceof RaceLogPathfinderEvent) {
|
||||
|
||||
+3
-11
@@ -5,22 +5,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogProtestStartTimeEvent;
|
||||
|
||||
public class ProtestStartTimeFinder extends RaceLogAnalyzer {
|
||||
public class ProtestStartTimeFinder extends RaceLogAnalyzer<TimePoint> {
|
||||
|
||||
public ProtestStartTimeFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public TimePoint getProtestStartTime() {
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
return searchForStartTime();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
}
|
||||
|
||||
private TimePoint searchForStartTime() {
|
||||
@Override
|
||||
protected TimePoint performAnalyzation() {
|
||||
for (RaceLogEvent event : getPassEventsDescending()) {
|
||||
if (event instanceof RaceLogProtestStartTimeEvent) {
|
||||
return ((RaceLogProtestStartTimeEvent) event).getProtestStartTime();
|
||||
|
||||
+20
-3
@@ -3,7 +3,13 @@ package com.sap.sailing.domain.racelog.analyzing.impl;
|
||||
import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
|
||||
public abstract class RaceLogAnalyzer {
|
||||
/**
|
||||
* Analyzer to perform a query over a given {@link RaceLog}. Each subclass defines its <code>ResultType</code>.
|
||||
*
|
||||
* @param <ResultType>
|
||||
* type of analyzation's result.
|
||||
*/
|
||||
public abstract class RaceLogAnalyzer<ResultType> {
|
||||
|
||||
protected RaceLog raceLog;
|
||||
|
||||
@@ -11,6 +17,17 @@ public abstract class RaceLogAnalyzer {
|
||||
this.raceLog = raceLog;
|
||||
}
|
||||
|
||||
public ResultType analyze() {
|
||||
raceLog.lockForRead();
|
||||
try {
|
||||
return performAnalyzation();
|
||||
} finally {
|
||||
raceLog.unlockAfterRead();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract ResultType performAnalyzation();
|
||||
|
||||
protected Iterable<RaceLogEvent> getPassEvents() {
|
||||
return raceLog.getFixes();
|
||||
}
|
||||
@@ -18,11 +35,11 @@ public abstract class RaceLogAnalyzer {
|
||||
protected Iterable<RaceLogEvent> getAllEvents() {
|
||||
return raceLog.getRawFixes();
|
||||
}
|
||||
|
||||
|
||||
protected Iterable<RaceLogEvent> getPassEventsDescending() {
|
||||
return raceLog.getFixesDescending();
|
||||
}
|
||||
|
||||
|
||||
protected Iterable<RaceLogEvent> getAllEventsDescending() {
|
||||
return raceLog.getRawFixesDescending();
|
||||
}
|
||||
|
||||
+3
-16
@@ -5,27 +5,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogRaceStatusEvent;
|
||||
|
||||
public class RaceStatusAnalyzer extends RaceLogAnalyzer {
|
||||
public class RaceStatusAnalyzer extends RaceLogAnalyzer<RaceLogRaceStatus> {
|
||||
|
||||
public RaceStatusAnalyzer(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public RaceLogRaceStatus getStatus() {
|
||||
|
||||
RaceLogRaceStatus newStatus = RaceLogRaceStatus.UNSCHEDULED;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
newStatus = searchForRaceStatus();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return newStatus;
|
||||
}
|
||||
|
||||
private RaceLogRaceStatus searchForRaceStatus() {
|
||||
@Override
|
||||
protected RaceLogRaceStatus performAnalyzation() {
|
||||
RaceLogRaceStatus newStatus = RaceLogRaceStatus.UNSCHEDULED;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
|
||||
+3
-13
@@ -5,24 +5,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStartProcedureChangedEvent;
|
||||
|
||||
public class StartProcedureTypeAnalyzer extends RaceLogAnalyzer {
|
||||
public class StartProcedureTypeAnalyzer extends RaceLogAnalyzer<StartProcedureType> {
|
||||
|
||||
public StartProcedureTypeAnalyzer(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public StartProcedureType getActiveStartProcedureType() {
|
||||
StartProcedureType result = null;
|
||||
raceLog.lockForRead();
|
||||
try {
|
||||
result = searchLog();
|
||||
} finally {
|
||||
raceLog.unlockAfterRead();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private StartProcedureType searchLog() {
|
||||
@Override
|
||||
protected StartProcedureType performAnalyzation() {
|
||||
StartProcedureType result = null;
|
||||
for (RaceLogEvent event : getAllEvents()) {
|
||||
if (event instanceof RaceLogStartProcedureChangedEvent) {
|
||||
|
||||
+3
-15
@@ -5,26 +5,14 @@ import com.sap.sailing.domain.racelog.RaceLog;
|
||||
import com.sap.sailing.domain.racelog.RaceLogEvent;
|
||||
import com.sap.sailing.domain.racelog.RaceLogStartTimeEvent;
|
||||
|
||||
public class StartTimeFinder extends RaceLogAnalyzer {
|
||||
public class StartTimeFinder extends RaceLogAnalyzer<TimePoint> {
|
||||
|
||||
public StartTimeFinder(RaceLog raceLog) {
|
||||
super(raceLog);
|
||||
}
|
||||
|
||||
public TimePoint getStartTime() {
|
||||
TimePoint startTime = null;
|
||||
|
||||
this.raceLog.lockForRead();
|
||||
try {
|
||||
startTime = searchForStartTime();
|
||||
} finally {
|
||||
this.raceLog.unlockAfterRead();
|
||||
}
|
||||
|
||||
return startTime;
|
||||
}
|
||||
|
||||
private TimePoint searchForStartTime() {
|
||||
@Override
|
||||
protected TimePoint performAnalyzation() {
|
||||
TimePoint startTime = null;
|
||||
|
||||
for (RaceLogEvent event : getPassEvents()) {
|
||||
|
||||
-2
@@ -29,8 +29,6 @@ public class RaceLogImpl extends TrackImpl<RaceLogEvent> implements RaceLog {
|
||||
private transient Set<RaceLogEventVisitor> listeners;
|
||||
private int currentPassId;
|
||||
|
||||
public static final int DefaultPassId = 0;
|
||||
|
||||
/**
|
||||
* Initializes a new {@link RaceLogImpl} with the default lock name.
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user