package p.packer.models;

import p.packer.messages.diagnostics.PackerDiagnosticCategory;
import p.packer.messages.diagnostics.PackerDiagnosticSeverity;

import java.nio.file.Path;
import java.util.Objects;

public record PackerDiagnostic(
        PackerDiagnosticSeverity severity,
        PackerDiagnosticCategory category,
        String message,
        Path evidencePath,
        boolean blocking) {

    public PackerDiagnostic {
        Objects.requireNonNull(severity, "severity");
        Objects.requireNonNull(category, "category");
        message = Objects.requireNonNull(message, "message").trim();
        evidencePath = evidencePath == null ? null : evidencePath.toAbsolutePath().normalize();
        if (message.isBlank()) {
            throw new IllegalArgumentException("message must not be blank");
        }
    }
}
