diff --git a/backend/src/main/java/org/raddatz/familienarchiv/document/SearchFilters.java b/backend/src/main/java/org/raddatz/familienarchiv/document/SearchFilters.java new file mode 100644 index 00000000..07ce4ab8 --- /dev/null +++ b/backend/src/main/java/org/raddatz/familienarchiv/document/SearchFilters.java @@ -0,0 +1,40 @@ +package org.raddatz.familienarchiv.document; + +import org.raddatz.familienarchiv.tag.TagOperator; + +import java.time.LocalDate; +import java.util.List; +import java.util.UUID; + +/** + * The filter predicates honoured by {@link DocumentService#searchDocuments} and + * {@link DocumentService#findIdsForFilter}. Sort, direction, and pagination are + * deliberately excluded — they are not filter predicates, and {@code findIdsForFilter} + * needs none of them; they are passed as separate arguments instead. + * + * Kept as a record so the ten values are passed as one named bundle instead of a + * positional argument list where two UUIDs (sender vs. receiver) or two dates + * (from vs. to) can be swapped by accident at the call site — a transposition that + * compiles cleanly and silently returns the wrong rows. + * + * Sibling of {@link DensityFilters} (= these fields minus from/to/undated); kept + * separate on purpose, so the density call path never reasons about date/undated + * fields it deliberately excludes. + */ +public record SearchFilters( + String text, + LocalDate from, + LocalDate to, + UUID sender, + UUID receiver, + List tags, + String tagQ, + DocumentStatus status, + TagOperator tagOperator, + boolean undated) { + + /** Returns a copy with {@code undated} overridden — used by the undated-count path. */ + public SearchFilters withUndated(boolean undated) { + return new SearchFilters(text, from, to, sender, receiver, tags, tagQ, status, tagOperator, undated); + } +}