zoukankan      html  css  js  c++  java
  • list<entity>转list<map>

    @SuppressWarnings("unchecked")
    public static <T> List<Map<String, Object>> listConvert(List<T> list) {
      List<Map<String, Object>> list_map = new ArrayList<Map<String, Object>>(); // 定义List<Map<String, Object>>数组<br>          // list为外部传进来的list集合
      if (list != null && list.size() > 0) {
        list.forEach(item ->{
          // PropertyUtils.describe(Object)转换
          Map<String, Object> map = new HashMap<String, Object>();;
          try {
            map = (Map<String, Object>) PropertyUtils.describe(item);
          } catch (Exception e) {
            e.printStackTrace();
          }
          list_map.add(map);
        });
      }
      return list_map;
    }

  • 相关阅读:
    3288 积木大赛
    3284 疯狂的黄大神
    1531 山峰
    1018 单词接龙
    1432 总数统计
    1507 酒厂选址
    1063 合并果子
    几个sort不能过的题目
    poj 2245 Lotto
    求两圆相交面积模板
  • 原文地址:https://www.cnblogs.com/baimj/p/14095902.html
Copyright © 2011-2022 走看看