Map工具-MapUtil
https://www.tabnine.com/code/java/methods/cn.hutool.core.map.MapUtil/toCamelCaseMap
How to usetoCamelCaseMapmethodincn.hutool.core.map.MapUtil
BeanUtil.fillBeanWithMap(...)
/**
* 使用Map填充Bean对象
*
* @param <T> Bean类型
* @param map Map
* @param bean Bean
* @param isToCamelCase 是否将Map中的下划线风格key转换为驼峰风格
* @param copyOptions 属性复制选项 {@link CopyOptions}
* @return Bean
* @since 3.3.1
*/
public static <T> T fillBeanWithMap(Map<?, ?> map, T bean, boolean isToCamelCase, CopyOptions copyOptions) {
if (MapUtil.isEmpty(map)) {
return bean;
}
if (isToCamelCase) {
map = MapUtil.toCamelCaseMap(map);
}
return BeanCopier.create(map, bean, copyOptions).copy();
}
BeanUtil.fillBeanWithMap(...)
/**
* 使用Map填充Bean对象
*
* @param <T> Bean类型
* @param map Map
* @param bean Bean
* @param isToCamelCase 是否将Map中的下划线风格key转换为驼峰风格
* @param copyOptions 属性复制选项 {@link CopyOptions}
* @return Bean
* @since 3.3.1
*/
public static <T> T fillBeanWithMap(Map<?, ?> map, T bean, boolean isToCamelCase, CopyOptions copyOptions) {
if (MapUtil.isEmpty(map)) {
return bean;
}
if (isToCamelCase) {
map = MapUtil.toCamelCaseMap(map);
}
return BeanCopier.create(map, bean, copyOptions).copy();
}
Record.toBean(...)
public <T> T toBean(Class<T> beanClass){
return (T)BeanUtil.mapToBean(MapUtil.toCamelCaseMap(this),beanClass,true);
//return BeanUtil.fillBeanWithMap(this,beanClass.newInstance(),true,)
}
BeanUtil.fillBeanWithMap(...)
/**
* 使用Map填充Bean对象
*
* @param <T> Bean类型
* @param map Map
* @param bean Bean
* @param isToCamelCase 是否将Map中的下划线风格key转换为驼峰风格
* @param copyOptions 属性复制选项 {@link CopyOptions}
* @return Bean
* @since 3.3.1
*/
public static <T> T fillBeanWithMap(Map<?, ?> map, T bean, boolean isToCamelCase, CopyOptions copyOptions) {
if (MapUtil.isEmpty(map)) {
return bean;
}
if (isToCamelCase) {
map = MapUtil.toCamelCaseMap(map);
}
return BeanCopier.create(map, bean, copyOptions).copy();
}
标签:map,bean,驼峰,Map,hutool,param,Bean,return
From: https://www.cnblogs.com/linhan8888/p/17874205.html