package org.raddatz.familienarchiv.person;

import lombok.Builder;

/**
 * The reader/triage filter set for the persons directory, threaded as one value through
 * {@code PersonController -> PersonService -> PersonRepository}. Each field is nullable:
 * null means "do not constrain on this dimension".
 *
 * <ul>
 *   <li>{@code type} — restrict to a single {@link PersonType}.</li>
 *   <li>{@code familyOnly} — when true, only {@code familyMember} persons.</li>
 *   <li>{@code hasDocuments} — when true, only persons with documentCount &gt; 0.</li>
 *   <li>{@code provisional} — match the {@code Person.provisional} flag exactly.</li>
 *   <li>{@code readerDefault} — when true, restrict to {@code familyMember OR documentCount > 0}
 *       (the clean reader view). The explicit filters above AND with this restriction.</li>
 * </ul>
 */
@Builder
public record PersonFilter(
        PersonType type,
        Boolean familyOnly,
        Boolean hasDocuments,
        Boolean provisional,
        boolean readerDefault
) {
    /** The unconstrained "show all" filter (transcriber view, no reader restriction). */
    public static PersonFilter showAll() {
        return PersonFilter.builder().readerDefault(false).build();
    }

    /** The clean reader default: familyMember OR documentCount &gt; 0, no other constraints. */
    public static PersonFilter cleanDefault() {
        return PersonFilter.builder().readerDefault(true).build();
    }
}
