June 2014
Beginner to intermediate
304 pages
7h 25m
English
Let's add a category view to the products page using the path variable:
ProductRepository interface and add one more method declaration on its getProductsByCategory method:List<Product> getProductsByCategory(String category);
InMemoryProductRepository and add an implementation for the previously declared method as follows:public List<Product> getProductsByCategory(String category) {
List<Product> productsByCategory = new ArrayList<Product>();
for(Product product: listOfProducts) {
if(category.equalsIgnoreCase(product.getCategory())){
productsByCategory.add(product);
}
}
return productsByCategory;
}ProductService interface and add one more ...