package at.procon.eventhub.processing.driverworkingtime.model;

import java.util.List;

public record DriverWorkingTimeDerivedProjectionBundle(
        List<DriverWorkingTimeDrivingInterruptionInterval> drivingInterruptionIntervals,
        List<DriverWorkingTimeDrivingInterruptionInterval> dailyWeeklyRestCandidateIntervals,
        List<DriverWorkingTimeRestCoverageInterval> dailyWeeklyRestCandidateCoverageIntervals,
        List<DriverWorkingTimeRestCoverageInterval> unclassifiedDailyWeeklyRestCandidateCoverageIntervals,
        List<DriverWorkingTimeDrivingInterruptionInterval> drivingInterruptionVehicleChangeIntervals,
        List<DriverWorkingTimeVuCardAbsentInterval> vuCardAbsentIntervals,
        List<DriverWorkingTimeRestCoverageInterval> potentialHomeOvernightStayIntervals,
        List<DriverWorkingTimeRestCoverageInterval> potentialInVehicleOvernightStayIntervals,
        List<DriverWorkingTimePotentialInVehicleTripInterval> potentialInVehicleTripIntervals
) {
    public DriverWorkingTimeDerivedProjectionBundle {
        drivingInterruptionIntervals = safe(drivingInterruptionIntervals);
        dailyWeeklyRestCandidateIntervals = safe(dailyWeeklyRestCandidateIntervals);
        dailyWeeklyRestCandidateCoverageIntervals = safe(dailyWeeklyRestCandidateCoverageIntervals);
        unclassifiedDailyWeeklyRestCandidateCoverageIntervals = safe(unclassifiedDailyWeeklyRestCandidateCoverageIntervals);
        drivingInterruptionVehicleChangeIntervals = safe(drivingInterruptionVehicleChangeIntervals);
        vuCardAbsentIntervals = safe(vuCardAbsentIntervals);
        potentialHomeOvernightStayIntervals = safe(potentialHomeOvernightStayIntervals);
        potentialInVehicleOvernightStayIntervals = safe(potentialInVehicleOvernightStayIntervals);
        potentialInVehicleTripIntervals = safe(potentialInVehicleTripIntervals);
    }

    private static <T> List<T> safe(List<T> values) {
        return values == null ? List.of() : List.copyOf(values);
    }
}
