add DriverNamePool

This commit is contained in:
Looly
2021-04-11 02:53:16 +08:00
parent 3a105e0334
commit c7f7c4c1f9
6 changed files with 239 additions and 67 deletions

View File

@@ -8,6 +8,7 @@ import net.sf.cglib.core.Converter;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -152,4 +153,31 @@ public class CglibUtil {
public static BeanMap toMap(Object bean) {
return BeanMap.create(bean);
}
/**
* 将Map中的内容填充至Bean中
* @param map Map
* @param bean Bean
* @param <T> Bean类型
* @return bean
* @since 5.6.3
*/
@SuppressWarnings("rawtypes")
public static <T> T fillBean(Map map, T bean){
BeanMap.create(bean).putAll(map);
return bean;
}
/**
* 将Map转换为Bean
* @param map Map
* @param beanClass Bean类
* @param <T> Bean类型
* @return bean
* @since 5.6.3
*/
@SuppressWarnings("rawtypes")
public static <T> T toBean(Map map, Class<T> beanClass){
return fillBean(map, ReflectUtil.newInstanceIfPossible(beanClass));
}
}