public Iterator<CommodityPO> findCommoditiesInKeyword(String key) { ArrayList<CommodityPO> output = new ArrayList<CommodityPO>(); Iterator<CommodityPO> iterator = set.iterator(); CommodityPO po = null; while (iterator.hasNext()) { po = iterator.next(); if (po.getId().contains(key) || po.getName().contains(key)) { output.add(po); } else { Iterator<CommodityPO.CommodityModelPO> it = po.getList().iterator(); while (it.hasNext()) { if (it.next().getName().contains(key) || it.next().getStorehouse().contains(key)) { output.add(po); } } } } return output.iterator(); }
public Iterator<CommodityPO> findCommoditiesInType(String id) { ArrayList<CommodityPO> list = new ArrayList<CommodityPO>(); Iterator<CommodityPO> iterator = set.iterator(); CommodityPO po = null; while (iterator.hasNext()) { po = iterator.next(); if (po.getId().substring(0, 11).equals(id)) { list.add(po); } } return list.iterator(); }