Below is the code for collecting listofmap from resultset and checking the listofmap for a perticular product, if product exists then get that map. Please help me to do it in java8
List<Map<String,Object>> lmProducts = new ArrayList<Map<String, Object>>();
Map<String, Object> map = null;
try {
if(resultSet.next()){
System.out.println("PRODUCT\t PRICE\t QUANTITY");
do{
map = new HashMap<String, Object>();
map.put("NAME", resultSet.getString("NAME"));
map.put("PRICE", resultSet.getString("PRICE"));
map.put("QUANTITY", resultSet.getString("QUANTITY"));
System.out.println(resultSet.getString("NAME")+"\t "+resultSet.getInt("PRICE")+"\t "+resultSet.getInt("QUANTITY"));
lmProducts.add(map);
}while (resultSet.next());
}
}catch (SQLException e){
System.out.println("Exception while processing Resultset: "+e.toString());
}
//Trying to get mProduct map by checking key condition
Map<String, Object> mProductMap = new HashMap<String, Object>();
mProductMap = lmProducts.stream().filter(m -> m.get("NAME").toString().equalsIgnoreCase(sProductName)).collect(to)