package p.packer.models;

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 PackerAssetDetails(
        PackerAssetSummary summary,
        OutputFormatCatalog outputFormat,
        OutputCodecCatalog outputCodec,
        List<OutputCodecCatalog> availableOutputCodecs,
        Map<OutputCodecCatalog, List<PackerCodecConfigurationField>> codecConfigurationFieldsByCodec,
        List<PackerCodecConfigurationField> metadataFields,
        Map<String, List<Path>> inputsByRole,
        List<PackerDiagnostic> diagnostics) {

    public PackerAssetDetails {
        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"));
    }
}
