日期:2014-05-19 浏览次数:20842 次
public class Bean2Map { public static HashMap format(TbAccount in){ HashMap map=new HashMap(); map.put(MyKey.TBACCOUNT.NAME, in.getName()); map.put(MyKey.TBACCOUNT.ACCOUNT, in.getAccount()); map.put(MyKey.TBACCOUNT.PASSWORD, in.getPassword()); map.put(MyKey.TBACCOUNT.SEX, in.getSex()); return map; } public static HashMap format(TbDish in){ HashMap map=new HashMap(); map.put(MyKey.TBDISH.NAME, in.getName()); map.put(MyKey.TBDISH.KIND, in.getKind().getName()); map.put(MyKey.TBDISH.PRICE, in.getPrice()+""); map.put(MyKey.TBDISH.ID, in.getDishId().toString()); return map; } public static HashMap format(TbRestaurant in){ HashMap map=new HashMap(); map.put(MyKey.TBRESTAURANT.ID, in.getRestaurantId().toString()); return map; } public static HashMap format(Object in){ HashMap map=new HashMap(); map.put("ob", "ob"); return map; } public static List<HashMap> formatDishList(List<TbDish> in){ List<HashMap> list=new ArrayList<HashMap>(); for (TbDish dish : in) { list.add(format(dish)); } return list; } public static <T> List<HashMap> format(List<T> in){ List<HashMap> list=new ArrayList<HashMap>(); for (T item : in) { list.add(format(item)); } return list; } }