mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-25 05:23:51 +00:00
introduced RankingMetric interface; minor performance improvements for compareTo methods in AbstractDistance and AbstractSpeedImpl
This commit is contained in:
1 parent
3f8b076562
commit
0701401499
3 files changed
+33
-2
No files matched your search
+3
-1
@@ -19,7 +19,9 @@ public abstract class AbstractDistance implements Distance {
|
||||
|
||||
@Override
|
||||
public int compareTo(Distance o) {
|
||||
return getMeters() > o.getMeters() ? 1 : getMeters() == o.getMeters() ? 0 : -1;
|
||||
final double meters = getMeters();
|
||||
final double otherMeters = o.getMeters();
|
||||
return meters > otherMeters ? 1 : meters == otherMeters ? 0 : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-1
@@ -36,7 +36,9 @@ public abstract class AbstractSpeedImpl implements Speed {
|
||||
|
||||
@Override
|
||||
public int compareTo(Speed speed) {
|
||||
return getMetersPerSecond() > speed.getMetersPerSecond() ? 1 : getMetersPerSecond() == speed.getMetersPerSecond() ? 0 : -1;
|
||||
final double metersPerSecond = getMetersPerSecond();
|
||||
final double otherMetersPerSecond = speed.getMetersPerSecond();
|
||||
return metersPerSecond > otherMetersPerSecond ? 1 : metersPerSecond == otherMetersPerSecond ? 0 : -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.sap.sailing.domain.ranking;
|
||||
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.tracking.TrackedRace;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
|
||||
/**
|
||||
* Evaluates a {@link Competitor}'s ranking metric, either by windward distance to overall leader in case of a
|
||||
* one-design class or according to some handicapping scheme. The metric produces a {@link Comparable} value of type
|
||||
* <code>T</code> which can be used to order competitors by rank.
|
||||
* <p>
|
||||
*
|
||||
* Furthermore, this metric knows how to evaluate a {@link Competitor}'s corrected time and how to compute the windward
|
||||
* distance to another competitor.
|
||||
* <p>
|
||||
*
|
||||
* A handicap-based metric may need to request specific parameters from the {@link Competitor} to judge the ranking
|
||||
* correctly, such as the time-on-time multiplier, the Yardstick number, the time-on-distance allowance or the complex
|
||||
* ORC Performance Curve rating.
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
* @param <T>
|
||||
*/
|
||||
public interface RankingMetric<T extends Comparable<T>> {
|
||||
T getRankingMetric(TrackedRace trackedRace, Competitor competitor, TimePoint timePoint);
|
||||
}
|
||||
Reference in new issue
Block a user