Java工具类(28)—bean转map工具类
package com.awifi.cloudnative.container.common.utils; import org.springframework.cglib.beans.BeanMap; import java.util.HashMap; import java.util.Map; /** * @Title: BeanMapUtils * @Description: bean map 转化类 * @Copyright: * @Company: * @author * @date 2020/8/8 11:53 */ public final class BeanMapUtils { /** * 将对象装换为map * @param bean T * @param <T> T * @return Map */ public static <T> Map<String, Object> beanToMap(T bean) { Map<String, Object> map = new HashMap<>(); if (bean != null) { BeanMap beanMap = BeanMap.create(bean); for (Object key : beanMap.keySet()) { map.put(key + "", beanMap.get(key)); } } return map; } private BeanMapUtils() { } }