public static Collection<OrderField<?>> getOrderFields(final Map<String, Field<?>> fieldMap,
                                                           final BaseCriteria criteria,
                                                           final OrderField<?>... defaultSortFields) {
        final List<OrderField<?>> defaults = NullSafe.asList(defaultSortFields);
        if (NullSafe.isEmptyCollection(criteria.getSortList())) {
            return defaults;
        } else {
            final List<OrderField<?>> defaultsNotSeen = new ArrayList<>(defaults);

            final ArrayList<OrderField<?>> sortList = criteria.getSortList()
                    .stream()
                    .map(s -> getOrderField(fieldMap, s))
                    .filter(Objects::nonNull)
                    .peek(defaultsNotSeen::remove)
                    .collect(Collectors.toCollection(ArrayList::new));

            // If the default sort fields are not in the sort list then add them at the end, so they act
            // as a secondary sort, e.g. if user is sorting on 'enabled' then it makes sense to secondary
            // sort on the default sort fields.
            if (!defaultsNotSeen.isEmpty()) {
                sortList.addAll(defaultsNotSeen);
            }

            return sortList;
        }
    }
Used to build jOOQ conditions from string criteria

@param field    The jOOQ field being queried
@param criteria The criteria to apply
@return A condition that applies the given criteria
stroom-db-util/src/main/java/stroom/db/util/JooqUtil.java