com.github.trang.copiers.MapCopiers Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of copiers Show documentation
Show all versions of copiers Show documentation
A Friendly Bean Copier Packaging.
package com.github.trang.copiers;
import com.github.trang.copiers.cglib.BeanToMapCopier;
import com.github.trang.copiers.cglib.MapToBeanCopier;
import java.util.List;
import java.util.Map;
/**
* MapCopiers 工具类,提供 Map 和 JavaBean 之间的相互拷贝
*
* @author trang
*/
public final class MapCopiers {
private MapCopiers() {
throw new UnsupportedOperationException();
}
/**
* 单个 Bean 转换为 Map
*
* @param bean 源对象
* @return map
*/
public static Map beanToMap(T bean) {
return new BeanToMapCopier<>().copy(bean);
}
/**
* 单个 Bean 转换为已经存在的 Map
*
* @param bean 源对象
* @param map map
*/
public static void beanToMap(T bean, Map map) {
new BeanToMapCopier<>().copy(bean, map);
}
/**
* Bean List 转换为 Map List
*
* @param list 源对象集合
* @return list
*/
public static List