package p.packer.models;

import java.util.Objects;

public record PackerAssetArtifactSelection(
        String artifactId,
        String file,
        int index,
        String fingerprint) {

    public PackerAssetArtifactSelection {
        artifactId = artifactId == null || artifactId.isBlank() ? null : artifactId.trim();
        file = Objects.requireNonNull(file, "file").trim();
        fingerprint = fingerprint == null || fingerprint.isBlank() ? null : fingerprint.trim();
        if (file.isBlank()) {
            throw new IllegalArgumentException("file must not be blank");
        }
        if (index < 0) {
            throw new IllegalArgumentException("index must be non-negative");
        }
    }
}
