From 1c961619f13a8e960f7d273c267445b07d94a9b1 Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 31 May 2026 15:07:10 +0200 Subject: [PATCH] refactor(document): introduce SearchFilters record (#683) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Filter-only value object bundling the ten search predicates so the long positional argument lists on the document search chain can be replaced with one named record — killing the sender/receiver and from/to swap-bug class. Mirrors the existing DensityFilters; carries a withUndated copy accessor for the forced-undated count path. Unused as of this commit. Co-Authored-By: Claude Sonnet 4.6 --- .../document/SearchFilters.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 backend/src/main/java/org/raddatz/familienarchiv/document/SearchFilters.java 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); + } +}