0
public Set<Product> getProductsBypriceFilter(Map<String, BigDecimal> filterParams) {
    Set<Product> productsByPrice = new HashSet<>();
    Set<String> criterias = filterParams.keySet();


    if (criterias.contains("low")) {
        for (Product product : listOfProducts) {
            if (product.getUnitPrice().compareTo(filterParams.get("low"))>=0  ) {
                productsByPrice.add(product);
            }
        }
    }
    return productsByPrice ;
}

I want to compare product price with "low" price from Map but I get error

java.util.LinkedList cannot be cast to java.math.BigDecimal

Is filterParams.get("low") a linkedlist of one value? I can't access it like List.

Qiu
  • 5,651
  • 10
  • 49
  • 56
user3551808
  • 95
  • 2
  • 8

1 Answers1

0

Your product.getUnitPrice() method seems to be returning a LinkedList object instead of a BigDecimal one. Since you did not supply the code for Product.getUnitPrice() it is hard to help you any further.

Pedro Borges
  • 1,568
  • 1
  • 14
  • 25