The given filtering condition is using the stream in JAVA 8 how do I change it without using stream. I have to filter the customer and employee commodities from the database in the controller
else if
("Employee".equalsIgnoreCase(soption))
{ customerVOs = customerVOs.stream()
.filter( s-> s.getRole().equalsIgnoreCase("Employee"))
.collect(Collectors.toList());
}
model.addAttribute("customerVOs", customerVOs);
customerVOs = customerVOs.stream()
.filter( s-> s.getRole().equalsIgnoreCase("Employee"))
.collect(Collectors.toList());
Can be written without stream as below,
for(var s: customerVOs){ // loop over your list from db
if(s.getRole().equalsIgnoreCase("Employee")){
// TODO add in list here
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.