This:
Timerange longest = Timerange.longest(breaks);
if (longest.durationInHours() >= MIN_FREE_HOURS)
return true;
is OK.
But this:
if (Timerange.longest(breaks).durationInHours() >= MIN_FREE_HOURS)
return true;
gives:
java.lang.ClassCastException
Do you know why?!
For simplicity:
public static final <T extends Timerange> T longest(List<T> timeranges) {
return timeranges.get(0);
}
Breaks:
List<Duty> breaks = week.substract(weekDuties);