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

import at.procon.eventhub.dto.EventHubEventDto;
import at.procon.eventhub.processing.dto.RuntimeDriverPartitionDebugDto;
import at.procon.eventhub.processing.dto.RuntimeSupportEvidenceNormalizationDebugDto;
import at.procon.eventhub.processing.eventprocessing.support.RuntimeSupportEvidenceEvent;
import at.procon.eventhub.processing.model.UnifiedDiscoveredVehicleRef;
import java.util.List;

public record DriverWorkingTimeDriverPartition(
        String driverKey,
        List<EventHubEventDto> driverSeedEvents,
        List<EventHubEventDto> attachedVehicleEvidenceEvents,
        List<EventHubEventDto> mergedEvents,
        List<UnifiedDiscoveredVehicleRef> discoveredVehicles,
        List<DriverWorkingTimeVehicleUsageInterval> vehicleUsageIntervals,
        RuntimeDriverPartitionDebugDto partitionDebug,
        List<RuntimeSupportEvidenceEvent> supportEvidenceEvents,
        RuntimeSupportEvidenceNormalizationDebugDto supportEvidenceNormalization,
        List<String> notes,
        List<String> warnings
) {
    public DriverWorkingTimeDriverPartition {
        driverSeedEvents = driverSeedEvents == null ? List.of() : List.copyOf(driverSeedEvents);
        attachedVehicleEvidenceEvents = attachedVehicleEvidenceEvents == null ? List.of() : List.copyOf(attachedVehicleEvidenceEvents);
        mergedEvents = mergedEvents == null ? List.of() : List.copyOf(mergedEvents);
        discoveredVehicles = discoveredVehicles == null ? List.of() : List.copyOf(discoveredVehicles);
        vehicleUsageIntervals = vehicleUsageIntervals == null ? List.of() : List.copyOf(vehicleUsageIntervals);
        supportEvidenceEvents = supportEvidenceEvents == null ? List.of() : List.copyOf(supportEvidenceEvents);
        notes = notes == null ? List.of() : List.copyOf(notes);
        warnings = warnings == null ? List.of() : List.copyOf(warnings);
    }

    public DriverWorkingTimeDriverPartition withSupportEvidence(
            List<RuntimeSupportEvidenceEvent> newSupportEvidenceEvents,
            RuntimeSupportEvidenceNormalizationDebugDto normalizationDebug,
            List<String> newNotes,
            List<String> newWarnings
    ) {
        return new DriverWorkingTimeDriverPartition(
                driverKey,
                driverSeedEvents,
                attachedVehicleEvidenceEvents,
                mergedEvents,
                discoveredVehicles,
                vehicleUsageIntervals,
                partitionDebug,
                newSupportEvidenceEvents,
                normalizationDebug,
                newNotes,
                newWarnings
        );
    }
}
