package de.gecheckt.pdf.umbenenner.application.port.out;

import java.util.Objects;

/**
 * Outcome of {@link TargetFolderPort#resolveUniqueFilename(String)} when the target file
 * at the proposed base name already exists <em>and</em> its binary content is identical
 * to the source document (same SHA-256 fingerprint).
 * <p>
 * This result signals to the application layer that no new copy is needed: the existing
 * target file is byte-for-byte identical to the source. The processing coordinator treats
 * this as a successful outcome — the document is considered already present in the target
 * folder under the given filename.
 *
 * @param existingFilename the filename of the already-existing identical target file,
 *                         including extension; never null or blank
 */
public record ExistingIdenticalTargetFile(String existingFilename)
        implements TargetFilenameResolutionResult {

    /**
     * Compact constructor validating the filename.
     *
     * @throws NullPointerException     if {@code existingFilename} is null
     * @throws IllegalArgumentException if {@code existingFilename} is blank
     */
    public ExistingIdenticalTargetFile {
        Objects.requireNonNull(existingFilename, "existingFilename must not be null");
        if (existingFilename.isBlank()) {
            throw new IllegalArgumentException("existingFilename must not be blank");
        }
    }
}
