I took the liberty of editing your post to format your source code — just added a line of three back-quotes before and after the code. Makes it easier to read.
The code looks sound (though Java’s not my best language). As an optimization & simplification, you can call trucksQuery.setGroupLevel(1): this will group together all rows with the same key, so you only get the unique keys in the result.
(Also, if you ever need to do this kind of merging manually: it’s much more efficient to use a Set, preferably a HashSet, instead of a List to collect the results, because contains is much faster. The code you have above runs in O(n^2) time, while using a HashSet it would be roughly O(n). Then afterwards you can copy the Set to a List and sort it.)
It’s a core Java class; or at least I assume it is, since there’s a HashMap, and a Set is just a Map without values. If Java doesn’t actually have a Set class, you can use a Map and just set the value to a placeholder like true.
Can you explain what “new criteria” means here?
Keep in mind that the map function has to be a pure function, i.e. it cannot use any external state including lexically-scoped values from an enclosing function. It has to give the same output every time if given the same input. That means any variable criteria can’t be part of the map function, they have to be used in the query.