Page<K2Agents> iterable = k2AgentsRepository.findAllByTeamIdIn(teamIds, pageRequest);
List<K2Agents> iterable1 = iterable.stream()
.filter(i->i.getLastName().equals(searchName))
.collect(Collectors.toList());
return iterable1;
I want to filter iterable by a string searchName. The final result should be a Page. In this code iterable1 return nothing.
First filter the Page<K2Agent> by using stream and finally create Page object using PageImpl
List<K2Agents> result = iterable.getContent()
.stream()
.filter(i->i.getLastName().equals(searchName))
.collect(Collectors.toList());
Page<K2Agent> r = new PageImpl<K2Agent>(result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With