|
@@ -1,5 +1,8 @@
|
|
|
package com.xynet.marketing.utils.collections.map;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import com.xynet.marketing.utils.Emptys;
|
|
|
+
|
|
|
import java.io.Serializable;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.sql.Timestamp;
|
|
@@ -114,4 +117,36 @@ public class JHashMap<K, V> extends HashMap<K, V> implements JMap<K, V>, Seriali
|
|
|
V v = this.get(key);
|
|
|
return v == null ? null : v;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将对象List转为MapList
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ * @param <T>
|
|
|
+ */
|
|
|
+ public static <T> List<Map<String, Object>> copy(List<T> list) {
|
|
|
+ if(Emptys.check(list)){
|
|
|
+ List<Map<String, Object>> result = new ArrayList<>(list.size());
|
|
|
+ list.forEach(item -> {
|
|
|
+ Map<String, Object> stringObjectMap = BeanUtil.beanToMap(item);
|
|
|
+ result.add(new JHashMap<>(stringObjectMap));
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将对象转为Map
|
|
|
+ * @param obj
|
|
|
+ * @return
|
|
|
+ * @param <T>
|
|
|
+ */
|
|
|
+ public static <T> Map<String, Object> copy(T obj) {
|
|
|
+ if(Emptys.check(obj)){
|
|
|
+ List<Map<String, Object>> copy = copy(Arrays.asList(obj));
|
|
|
+ return copy.get(0);
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|