mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-02 01:00:46 +00:00
Race list - Added utility method to compare start dates
This commit is contained in:
1 parent
626065c4d5
commit
71f289fa3b
1 file changed
+25
+25
@@ -33,6 +33,21 @@ public class RaceListDataUtil {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static <T extends RaceMetadataDTO> boolean hasDifferentValues(Collection<T> races, ValueProvider<T, ?> valueProvider) {
|
||||
Object compareValue = null;
|
||||
for (T race : races) {
|
||||
Object currentValue = valueProvider.getValue(race);
|
||||
if (currentValue == null) {
|
||||
continue;
|
||||
} else if (compareValue == null) {
|
||||
compareValue = currentValue;
|
||||
} else if (!compareValue.equals(currentValue)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static <T extends RaceMetadataDTO> boolean hasFleets(Collection<T> data) {
|
||||
return hasValues(data, new ValueProvider<T, FleetMetadataDTO>() {
|
||||
@Override
|
||||
@@ -104,4 +119,14 @@ public class RaceListDataUtil {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final long DAY_IN_MILLIS = 1000 * 60 * 60 * 24;
|
||||
public static <T extends RaceMetadataDTO> boolean hasDifferentStartDates(Collection<T> data) {
|
||||
return hasDifferentValues(data, new ValueProvider<T, Long>() {
|
||||
@Override
|
||||
public Long getValue(T object) {
|
||||
return object.getStart().getTime() / DAY_IN_MILLIS;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user