diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/client/place/event/partials/racelist/RaceListDataUtil.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/client/place/event/partials/racelist/RaceListDataUtil.java index 164dbea4bb1..d2ae7846495 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/client/place/event/partials/racelist/RaceListDataUtil.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/client/place/event/partials/racelist/RaceListDataUtil.java @@ -33,6 +33,21 @@ public class RaceListDataUtil { return false; } + private static boolean hasDifferentValues(Collection races, ValueProvider 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 boolean hasFleets(Collection data) { return hasValues(data, new ValueProvider() { @Override @@ -104,4 +119,14 @@ public class RaceListDataUtil { } }); } + + private static final long DAY_IN_MILLIS = 1000 * 60 * 60 * 24; + public static boolean hasDifferentStartDates(Collection data) { + return hasDifferentValues(data, new ValueProvider() { + @Override + public Long getValue(T object) { + return object.getStart().getTime() / DAY_IN_MILLIS; + } + }); + } }