join
Joins the fragments that carry anything, merging their parameters.
Empty fragments are dropped rather than producing a dangling separator, so a list built with listOfNotNull and a few nulls in it joins to exactly the conditions that survived. Joining nothing gives an empty fragment, which a clause then leaves out entirely - and prefix and postfix are dropped with it, so an empty filter cannot render a bare WHERE ().
Each fragment is parenthesised, which is not cosmetic: "a = 1 OR b = 2" joined to "c = 3" with " AND " means (a = 1 OR b = 2) AND (c = 3), and without the parentheses AND would bind tighter and quietly change which rows come back. Turn it off with addParenthesis only where every fragment is a single term.
Return
One fragment carrying every surviving condition and every parameter they name.
Parameters
What to put between the fragments - " AND " and " OR " being the two that come up.
Put in front of the whole thing where it renders at all, "WHERE " for a hand-written query. The builders supply their own keyword, so leave it empty there.
Put after the whole thing where it renders at all.
Whether to wrap each fragment. Leave it on unless you know every one is a single term.
Throws
INVALID_ARGUMENT where two fragments name the same parameter with different values. One would replace the other, and which one would depend on the order the filters were listed in.