public Optional<Sort> build(List<RequestSort> requestSortList, FieldMapper fieldMapper) { Iterator<RequestSort> iterator = requestSortList.iterator(); Sort sort = null; if (iterator.hasNext()) { RequestSort requestSort = iterator.next(); sort = new Sort( SORT_MAPPING.get(requestSort.getType()), fieldMapper.get(requestSort.getFieldName())); } while (iterator.hasNext()) { RequestSort requestSort = iterator.next(); sort = sort.and( new Sort( SORT_MAPPING.get(requestSort.getType()), fieldMapper.get(requestSort.getFieldName()))); } return Optional.ofNullable(sort); }
public Optional<Sort> build(List<RequestSort> requestSortList) { return build(requestSortList, FieldMapper.of(Maps.<String, String>newHashMap())); }