@Override public Set<Product> getProductsByFilter(Map<String, List<String>> filterParams) { Set<Product> productsByBrand = new HashSet<Product>(); Set<Product> productsByCategory = new HashSet<Product>(); Set<String> criterias = filterParams.keySet(); if (criterias.contains("brand")) { for (String brandName : filterParams.get("brand")) { for (Product product : listOfProducts) { if (brandName.equalsIgnoreCase(product.getManufacturer())) { productsByBrand.add(product); } } } } if (criterias.contains("category")) { for (String category : filterParams.get("category")) { productsByCategory.addAll(this.getProductsByCategory(category)); } } if (productsByCategory.size() == 0) { return productsByBrand; } productsByCategory.retainAll(productsByBrand); return productsByCategory; }
public Set<Product> getProductsByFilter(Map<String, List<String>> filterParams) { // TODO Auto-generated method stub Set<Product> productsByBrand = new HashSet<Product>(); Set<Product> productsByCategory = new HashSet<Product>(); Set<String> criterias = filterParams.keySet(); if (criterias.contains("brand")) { for (String brandName : filterParams.get("brand")) { for (Product product : listOfProducts) { if (brandName.equalsIgnoreCase(product.getManufacturer())) { productsByBrand.add(product); } } } } if (criterias.contains("category")) { for (String category : filterParams.get("category")) { productsByCategory.addAll(this.getProductsByCategory(category)); } } // if (criterias.contains("low")) { // for (String category : filterParams.get("category")) { // productsByCategory.addAll(this.getProductsByCategory(category)); // } // } productsByCategory.retainAll(productsByBrand); return productsByCategory; }
@Override public List<Product> getProductsByManufacturer(String manufacturer) { List<Product> productsByManufacturer = new ArrayList<Product>(); for (Product product : listOfProducts) { if (manufacturer.equalsIgnoreCase(product.getManufacturer())) { productsByManufacturer.add(product); } } return productsByManufacturer; }
public List<Product> getProductsByManufacturer(String manufacturer) { // TODO Auto-generated method stub List<Product> productsByManufacturer = new ArrayList<Product>(); for (Product product : listOfProducts) { if (manufacturer.equalsIgnoreCase(product.getManufacturer())) { productsByManufacturer.add(product); } } return productsByManufacturer; }