package p.packer.dtos;

import java.util.List;
import java.util.Objects;

public record PackerPackExecutionSummaryDTO(
        String canonicalArtifactName,
        int packedAssetCount,
        long elapsedMillis,
        List<PackerEmittedArtifactDTO> emittedArtifacts) {

    public PackerPackExecutionSummaryDTO {
        canonicalArtifactName = Objects.requireNonNull(canonicalArtifactName, "canonicalArtifactName").trim();
        emittedArtifacts = List.copyOf(Objects.requireNonNull(emittedArtifacts, "emittedArtifacts"));
        if (canonicalArtifactName.isBlank()) {
            throw new IllegalArgumentException("canonicalArtifactName must not be blank");
        }
        if (packedAssetCount < 0) {
            throw new IllegalArgumentException("packedAssetCount must not be negative");
        }
        if (elapsedMillis < 0L) {
            throw new IllegalArgumentException("elapsedMillis must not be negative");
        }
    }
}
