mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +08:00
修复JsonUtil.toBean
泛型数组类型丢失问题(pr#3876@Github)
This commit is contained in:
parent
9b19bf84a8
commit
0585b3c6b7
@ -73,8 +73,6 @@ public class ValueProviderToBeanCopier<T> extends AbsCopier<ValueProvider<String
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取目标字段真实类型
|
||||
final Type fieldType = TypeUtil.getActualType(this.targetType ,propDesc.getFieldType());
|
||||
// 编辑键值对
|
||||
final MutableEntry<Object, Object> entry = copyOptions.editField(tFieldName, null);
|
||||
if(null == entry){
|
||||
@ -89,6 +87,8 @@ public class ValueProviderToBeanCopier<T> extends AbsCopier<ValueProvider<String
|
||||
if(!source.containsKey(tFieldName)){
|
||||
return;
|
||||
}
|
||||
// 获取目标字段真实类型
|
||||
final Type fieldType = TypeUtil.getActualType(this.targetType ,propDesc.getFieldType());
|
||||
final Object sValue = source.value(tFieldName, fieldType);
|
||||
|
||||
// 检查目标对象属性是否过滤属性
|
||||
|
@ -85,14 +85,13 @@ public class ActualTypeMapperPool {
|
||||
public static Type getActualType(final Type type, final GenericArrayType genericArrayType) {
|
||||
final Map<Type, Type> typeTypeMap = get(type);
|
||||
Type actualType = typeTypeMap.get(genericArrayType);
|
||||
|
||||
if (actualType == null) {
|
||||
// 获取泛型数组元素泛型对应的确切类型
|
||||
final Type componentType = typeTypeMap.get(genericArrayType.getGenericComponentType());
|
||||
if (!(componentType instanceof Class<?>)) {
|
||||
return null;
|
||||
if (componentType instanceof Class) {
|
||||
actualType = ArrayUtil.getArrayType((Class<?>) componentType);
|
||||
typeTypeMap.put(genericArrayType, actualType);
|
||||
}
|
||||
actualType = ArrayUtil.getArrayType((Class<?>) componentType);
|
||||
typeTypeMap.put(genericArrayType, actualType);
|
||||
}
|
||||
|
||||
return actualType;
|
||||
|
Loading…
Reference in New Issue
Block a user