package p.packer.dtos;

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

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, Object> outputPipeline,
        PackerBankCompositionDetailsDTO bankComposition,
        List<Map<String, Object>> pipelinePalettes,
        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"));
        outputPipeline = Map.copyOf(Objects.requireNonNull(outputPipeline, "outputPipeline"));
        bankComposition = Objects.requireNonNull(bankComposition, "bankComposition");
        pipelinePalettes = List.copyOf(Objects.requireNonNull(pipelinePalettes, "pipelinePalettes"));
        diagnostics = List.copyOf(Objects.requireNonNull(diagnostics, "diagnostics"));
    }
}
