mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add DriverNamePool
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user