Refactor CriterionFactory for clearer generics handling