package p.packer.dtos;

import p.packer.messages.assets.OutputCodecCatalog;
import p.packer.messages.assets.OutputFormatCatalog;

import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Objects;

public record PackerAssetDetailsDTO(
        PackerAssetSummaryDTO summary,
        OutputFormatCatalog outputFormat,
        OutputCodecCatalog outputCodec,
        List<OutputCodecCatalog> availableOutputCodecs,
        Map<OutputCodecCatalog, List<PackerCodecConfigurationFieldDTO>> codecConfigurationFieldsByCodec,
        List<PackerCodecConfigurationFieldDTO> metadataFields,
        Map<String, List<Path>> inputsByRole,
        List<PackerDiagnosticDTO> diagnostics) {

    public PackerAssetDetailsDTO {
        Objects.requireNonNull(summary, "summary");
        outputFormat = Objects.requireNonNullElse(outputFormat, OutputFormatCatalog.UNKNOWN);
        outputCodec = Objects.requireNonNullElse(outputCodec, OutputCodecCatalog.UNKNOWN);
        availableOutputCodecs = List.copyOf(Objects.requireNonNull(availableOutputCodecs, "availableOutputCodecs"));
        codecConfigurationFieldsByCodec = Map.copyOf(Objects.requireNonNull(codecConfigurationFieldsByCodec, "codecConfigurationFieldsByCodec"));
        metadataFields = List.copyOf(Objects.requireNonNull(metadataFields, "metadataFields"));
        inputsByRole = Map.copyOf(Objects.requireNonNull(inputsByRole, "inputsByRole"));
        diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
    }
}
