- 通过Lambda filter过滤条件, 结果为false, 不输出集合
List<Producer> list = new ArrayList<>();
Collections.addAll(list, new Producer("01", new BigDecimal(3.13)), new Producer("02", new BigDecimal(3.14)));
list.stream().filter(producer -> {
BigDecimal yuanPrice = new BigDecimal(200);
BigDecimal xianPrice = new BigDecimal(100);
// 原价、现价
// yuanPrice > xianPrice = 1
// yuanPrice > xianPrice = -1
// yuanPrice = xianPrice = 0
return yuanPrice.compareTo(xianPrice) == -1 ? false : true; //true会输出, false不会输出
}).forEach(print -> System.out.println(JSON.toJSON(print)));
/*TODO: {"name":"01","mony":3.12999999999999989341858963598497211933135986328125} {"name":"02","mony":3.140000000000000124344978758017532527446746826171875}*/