package p.packer.messages;

import p.packer.messages.assets.OutputCodecCatalog;

import java.util.Map;
import java.util.Objects;

public record UpdateAssetContractRequest(
        PackerProjectContext project,
        AssetReference assetReference,
        boolean preloadEnabled,
        OutputCodecCatalog outputCodec,
        Map<String, String> codecFieldValues,
        Map<String, String> metadataFieldValues) {

    public UpdateAssetContractRequest {
        Objects.requireNonNull(project, "project");
        Objects.requireNonNull(assetReference, "assetReference");
        outputCodec = Objects.requireNonNullElse(outputCodec, OutputCodecCatalog.UNKNOWN);
        codecFieldValues = Map.copyOf(Objects.requireNonNullElse(codecFieldValues, Map.of()));
        metadataFieldValues = Map.copyOf(Objects.requireNonNullElse(metadataFieldValues, Map.of()));
    }
}
