Created
September 25, 2022 11:09
-
-
Save GayanM/0b71ac4190b9db85dd1f973a1df13087 to your computer and use it in GitHub Desktop.
Obtain a data map with list of product name by category
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @RequestMapping("/product-category") | |
| Map<String, List<String>> getProductsByCategory(List<Product> productList) { | |
| return productRepos.findAll().stream().collect(Collectors.groupingBy(com.mycompany.functional.programming. | |
| exercises.models.Product::getCategory, Collectors.mapping(product -> product.getName(), | |
| Collectors.toList()))); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment