| | |
| | | import org.springframework.cglib.beans.BeanMap; |
| | | import org.springframework.cglib.core.Converter; |
| | | |
| | | import java.util.LinkedHashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | } |
| | | |
| | | /** |
| | | * map拷贝到map |
| | | * |
| | | * @param map 数据来源 |
| | | * @param clazz 返回的对象类型 |
| | | * @return map对象 |
| | | */ |
| | | public static <T, V> Map<String, V> mapToMap(Map<String, T> map, Class<V> clazz) { |
| | | if (MapUtil.isEmpty(map)) { |
| | | return null; |
| | | } |
| | | if (ObjectUtil.isNull(clazz)) { |
| | | return null; |
| | | } |
| | | Map<String, V> copyMap = new LinkedHashMap<>(map.size()); |
| | | map.forEach((k, v) -> copyMap.put(k, copy(v, clazz))); |
| | | return copyMap; |
| | | } |
| | | |
| | | /** |
| | | * BeanCopier属性缓存<br> |
| | | * 缓存用于防止多次反射造成的性能问题 |
| | | * |
| | |
| | | private String genKey(Class<?> srcClass, Class<?> targetClass, Converter converter) { |
| | | final StringBuilder key = StrUtil.builder() |
| | | .append(srcClass.getName()).append('#').append(targetClass.getName()); |
| | | if(null != converter){ |
| | | if (null != converter) { |
| | | key.append('#').append(converter.getClass().getName()); |
| | | } |
| | | return key.toString(); |