package at.procon.eventhub.processing.dto;

import at.procon.eventhub.processing.model.UnifiedDiscoveredVehicleRef;
import at.procon.eventhub.processing.model.UnifiedRuntimeProcessingRequest;
import at.procon.eventhub.processing.driverworkingtime.dto.DriverWorkingTimeProcessingResultDto;
import java.util.List;

public record UnifiedRuntimeDerivedProjectionResultDto(
        UnifiedRuntimeProcessingRequest request,
        int driverSeedEventCount,
        int discoveredVehicleCount,
        int expandedVehicleEventCount,
        int mergedEventCount,
        List<UnifiedDiscoveredVehicleRef> discoveredVehicles,
        DriverWorkingTimeProcessingResultDto projection,
        List<String> notes,
        RuntimeSupportEvidenceNormalizationDebugDto supportEvidenceNormalization,
        RuntimeDriverPartitionDebugDto partitionDebug
) {
    public UnifiedRuntimeDerivedProjectionResultDto {
        discoveredVehicles = discoveredVehicles == null ? List.of() : List.copyOf(discoveredVehicles);
        notes = notes == null ? List.of() : List.copyOf(notes);
    }

    public UnifiedRuntimeDerivedProjectionResultDto(
            UnifiedRuntimeProcessingRequest request,
            int driverSeedEventCount,
            int discoveredVehicleCount,
            int expandedVehicleEventCount,
            int mergedEventCount,
            List<UnifiedDiscoveredVehicleRef> discoveredVehicles,
            DriverWorkingTimeProcessingResultDto projection,
            List<String> notes
    ) {
        this(
                request,
                driverSeedEventCount,
                discoveredVehicleCount,
                expandedVehicleEventCount,
                mergedEventCount,
                discoveredVehicles,
                projection,
                notes,
                null,
                null
        );
    }

    public UnifiedRuntimeDerivedProjectionResultDto(
            UnifiedRuntimeProcessingRequest request,
            int driverSeedEventCount,
            int discoveredVehicleCount,
            int expandedVehicleEventCount,
            int mergedEventCount,
            List<UnifiedDiscoveredVehicleRef> discoveredVehicles,
            DriverWorkingTimeProcessingResultDto projection,
            List<String> notes,
            RuntimeSupportEvidenceNormalizationDebugDto supportEvidenceNormalization
    ) {
        this(
                request,
                driverSeedEventCount,
                discoveredVehicleCount,
                expandedVehicleEventCount,
                mergedEventCount,
                discoveredVehicles,
                projection,
                notes,
                supportEvidenceNormalization,
                null
        );
    }



    public UnifiedRuntimeDerivedProjectionResultDto withPartitionDebug(RuntimeDriverPartitionDebugDto debug) {
        return new UnifiedRuntimeDerivedProjectionResultDto(
                request,
                driverSeedEventCount,
                discoveredVehicleCount,
                expandedVehicleEventCount,
                mergedEventCount,
                discoveredVehicles,
                projection,
                notes,
                supportEvidenceNormalization,
                debug
        );
    }
}
