public boolean containInKeyword(String key) { Iterator<CommodityPO> iterator = set.iterator(); CommodityPO po = null; while (iterator.hasNext()) { po = iterator.next(); if (po.getId().contains(key) || po.getName().contains(key)) { return true; } else { Iterator<CommodityPO.CommodityModelPO> it = po.getList().iterator(); while (it.hasNext()) { if (it.next().getName().contains(key) || it.next().getStorehouse().contains(key)) { return true; } } } } return false; }
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(); }