Details
-
Improvement
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
None
-
Platform Sprint 140
Description
Currently, you'd be required to write the following code:
if (sortBy != null && !sortBy.isEmpty()) { if (sortOrder == null || sortOrder.isEmpty() || "descending".equals(sortOrder)) { HstQueryBuilder.create(scope) .ofTypes(docType) .orderByDescending(sortBy) .limit(pageSize) .offset(pageSize * (crPage - 1)) .build(); } else { HstQueryBuilder.create(scope) .ofTypes(docType) .orderByAscescending(sortBy) .limit(pageSize) .offset(pageSize * (crPage - 1)) .build(); hstQuery.addOrderByAscending(sortBy); } }
The above is really unhandy. I want to be able to write
HstQueryBuilder.create(scope) .ofTypes(docType) .sortBy(sortOrder, sortBy) .limit(pageSize) .offset(pageSize * (crPage - 1)) .build();
and if and only if sortOrder.equals("descending") (case insentive), then sort descending.
NOTE I also want to rename orderByAscescending to sortByAscescending (also for descending).
The above logic also goes for sort by case insensitive