com.starmcc.qmdata.util.ConvertUtil Maven / Gradle / Ivy
package com.starmcc.qmdata.util;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.sf.cglib.beans.BeanMap;
import java.util.List;
import java.util.Map;
/**
* @author qm
* @date 2018年11月24日 上午1:57:19
* @Description List、Map工具类
*/
public final class ConvertUtil {
private ConvertUtil() {
}
/**
* @param bean
* @return
* @Description 将对象装换为map
*/
public final static Map beanToMap(T bean) {
Map map = Maps.newHashMap();
if (bean != null) {
BeanMap beanMap = BeanMap.create(bean);
for (Object key : beanMap.keySet()) {
map.put(key + "", beanMap.get(key));
}
}
return map;
}
/**
* 将map装换为javabean对象
*
* @param map
* @param bean
* @return
* @Description 将map装换为javabean对象
*/
public final static T mapToBean(Map map, T bean) {
BeanMap beanMap = BeanMap.create(bean);
beanMap.putAll(map);
return bean;
}
/**
* @param objList
* @return
* @Description 将List转换为List