mirror of
https://gitee.com/dromara/hutool.git
synced 2025-06-28 04:35:14 +08:00
!1345 优化XXXToMapCopier的部分性能
Merge pull request !1345 from IzayoiYurin/v5-dev
This commit is contained in:
commit
4e1b468096
@ -44,6 +44,9 @@ public class BeanToMapCopier extends AbsCopier<Object, Map> {
|
|||||||
actualEditable = copyOptions.editable;
|
actualEditable = copyOptions.editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 提前获取目标值真实类型
|
||||||
|
final Type[] earlyDetectTypeArguments = TypeUtil.getTypeArguments(this.targetType);
|
||||||
|
|
||||||
final Map<String, PropDesc> sourcePropDescMap = BeanUtil.getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
|
final Map<String, PropDesc> sourcePropDescMap = BeanUtil.getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
|
||||||
sourcePropDescMap.forEach((sFieldName, sDesc) -> {
|
sourcePropDescMap.forEach((sFieldName, sDesc) -> {
|
||||||
if (null == sFieldName || false == sDesc.isReadable(copyOptions.transientSupport)) {
|
if (null == sFieldName || false == sDesc.isReadable(copyOptions.transientSupport)) {
|
||||||
@ -68,11 +71,10 @@ public class BeanToMapCopier extends AbsCopier<Object, Map> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取目标值真实类型并转换源值
|
// 尝试转换源值
|
||||||
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
|
if(null != earlyDetectTypeArguments && earlyDetectTypeArguments.length > 1){
|
||||||
if(null != typeArguments && typeArguments.length > 1){
|
|
||||||
//sValue = Convert.convertWithCheck(typeArguments[1], sValue, null, this.copyOptions.ignoreError);
|
//sValue = Convert.convertWithCheck(typeArguments[1], sValue, null, this.copyOptions.ignoreError);
|
||||||
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
|
sValue = this.copyOptions.convertField(earlyDetectTypeArguments[1], sValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自定义值
|
// 自定义值
|
||||||
|
@ -33,6 +33,10 @@ public class MapToMapCopier extends AbsCopier<Map, Map> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map copy() {
|
public Map copy() {
|
||||||
|
|
||||||
|
// 提前获取目标值真实类型
|
||||||
|
final Type[] earlyDetectTypeArguments = TypeUtil.getTypeArguments(this.targetType);
|
||||||
|
|
||||||
this.source.forEach((sKey, sValue) -> {
|
this.source.forEach((sKey, sValue) -> {
|
||||||
if (null == sKey) {
|
if (null == sKey) {
|
||||||
return;
|
return;
|
||||||
@ -57,11 +61,10 @@ public class MapToMapCopier extends AbsCopier<Map, Map> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取目标值真实类型并转换源值
|
// 尝试转换源值
|
||||||
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
|
if (null != earlyDetectTypeArguments) {
|
||||||
if (null != typeArguments) {
|
|
||||||
//sValue = Convert.convertWithCheck(typeArguments[1], sValue, null, this.copyOptions.ignoreError);
|
//sValue = Convert.convertWithCheck(typeArguments[1], sValue, null, this.copyOptions.ignoreError);
|
||||||
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
|
sValue = this.copyOptions.convertField(earlyDetectTypeArguments[1], sValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 自定义值
|
// 自定义值
|
||||||
|
Loading…
Reference in New Issue
Block a user