I have list SortCriteria
objects. object contains properties is sortColumn
and sortAscending
. I need to iterate list if sortAscending
is true
I need add "ASC"
else I need add "DESC"
I have tried get the stream ascending list and stream of descending list and merging.
JSON:
"sort_criteria": [{
"sortAscending": true,
"sortColumn": "Category"
}]
JAVA LOGIC:
List<SortCriteria> listOfSortCriteria=webQueryRequest.getSortCriteria();
List<SortCriteria> listOfAscending=listOfSortCriteria.stream().filter(e->e.getSortAscending().equals("true")).collect(Collectors.toList());
List<SortCriteria> listOfDescending=listOfSortCriteria.stream().filter(e->e.getSortAscending().equals("false")).collect(Collectors.toList());
orderByQuery=ORDER_BY+listOfAscending.stream().map(e->e.getSortColumn()+ " "+"ASC").collect(Collectors.joining(","))+","+listOfDescending.stream().map(e->e.getSortColumn()+" "+"DESC").collect(Collectors.joining(","));
Instead of getting the stream ascending list and stream of descending list and merging I want to do at one time need final constructed result.