下面是从结果集中收集listofmap并检查特定产品的listofmap的代码,如果产品存在则获取该映射.
请帮我在java8中完成它
List> lmProducts = new ArrayList>();
Map map = null;
try {
if(resultSet.next()){
System.out.println("PRODUCT PRICE QUANTITY");
do{
map = new HashMap();
map.put("NAME", resultSet.getString("NAME"));
map.put("PRICE", resultSet.getString("PRICE"));
map.put("QUANTITY", resultSet.getString("QUANTITY"));
System.out.println(resultSet.getString("NAME")+" "+resultSet.getInt("PRICE")+" "+resultSet.getInt("QUANTITY"));
lmProducts.add(map);
}while (resultSet.next());
}
}catch (SQLException e){
System.out.println("Exception while processing Resultset: "+e.toString());
}
//尝试通过检查关键条件来获取mProduct映射
Map mProductMap = new HashMap();
mProductMap = lmProducts.stream().filter(m -> m.get("NAME").toString().equalsIgnoreCase(sProductName)).collect(to)