package at.procon.eventhub.processing.model;

import at.procon.eventhub.dto.EventHubEventDto;
import at.procon.eventhub.processing.dto.RuntimeDriverPartitionDebugDto;
import at.procon.eventhub.processing.dto.RuntimeVehicleEvidenceAttachmentDecisionDto;
import at.procon.eventhub.processing.dto.RuntimeVehicleUsageIntervalDebugDto;
import java.util.List;

public record RuntimeDriverVehicleEvidenceAttachmentResult(
        String driverKey,
        List<EventHubEventDto> directDriverEvents,
        List<EventHubEventDto> attachedVehicleEvidenceEvents,
        List<EventHubEventDto> mergedEvents,
        int vehicleUsageIntervalCount,
        int candidateVehicleEvidenceEventCount,
        int ignoredVehicleEvidenceEventCount,
        List<RuntimeVehicleUsageIntervalDebugDto> vehicleUsageIntervals,
        List<RuntimeVehicleEvidenceAttachmentDecisionDto> vehicleEvidenceDecisions,
        List<String> notes,
        List<String> warnings
) {
    public RuntimeDriverVehicleEvidenceAttachmentResult {
        directDriverEvents = directDriverEvents == null ? List.of() : List.copyOf(directDriverEvents);
        attachedVehicleEvidenceEvents = attachedVehicleEvidenceEvents == null ? List.of() : List.copyOf(attachedVehicleEvidenceEvents);
        mergedEvents = mergedEvents == null ? List.of() : List.copyOf(mergedEvents);
        vehicleUsageIntervals = vehicleUsageIntervals == null ? List.of() : List.copyOf(vehicleUsageIntervals);
        vehicleEvidenceDecisions = vehicleEvidenceDecisions == null ? List.of() : List.copyOf(vehicleEvidenceDecisions);
        notes = notes == null ? List.of() : List.copyOf(notes);
        warnings = warnings == null ? List.of() : List.copyOf(warnings);
    }

    public RuntimeDriverPartitionDebugDto toPartitionDebug() {
        return new RuntimeDriverPartitionDebugDto(
                driverKey,
                directDriverEvents.size(),
                vehicleUsageIntervalCount,
                candidateVehicleEvidenceEventCount,
                attachedVehicleEvidenceEvents.size(),
                ignoredVehicleEvidenceEventCount,
                mergedEvents.size(),
                vehicleUsageIntervals,
                vehicleEvidenceDecisions,
                notes,
                warnings
        );
    }
}
