mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
优化XXXToMapCopier的部分性能(pr#1345@Gitee)
This commit is contained in:
@@ -63,6 +63,9 @@ public class BeanToMapCopier extends AbsCopier<Object, Map> {
|
|||||||
actualEditable = copyOptions.editable;
|
actualEditable = copyOptions.editable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 提前获取目标值真实类型
|
||||||
|
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
|
||||||
|
|
||||||
final Map<String, PropDesc> sourcePropDescMap = getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
|
final Map<String, PropDesc> sourcePropDescMap = getBeanDesc(actualEditable).getPropMap(copyOptions.ignoreCase);
|
||||||
sourcePropDescMap.forEach((sFieldName, sDesc) -> {
|
sourcePropDescMap.forEach((sFieldName, sDesc) -> {
|
||||||
if (null == sFieldName || !sDesc.isReadable(copyOptions.transientSupport)) {
|
if (null == sFieldName || !sDesc.isReadable(copyOptions.transientSupport)) {
|
||||||
@@ -89,7 +92,7 @@ public class BeanToMapCopier extends AbsCopier<Object, Map> {
|
|||||||
sValue = entry.getValue();
|
sValue = entry.getValue();
|
||||||
|
|
||||||
// 获取目标值真实类型并转换源值
|
// 获取目标值真实类型并转换源值
|
||||||
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
|
// 尝试转换源值
|
||||||
if(null != typeArguments && typeArguments.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 = copyOptions.convertField(typeArguments[1], sValue);
|
sValue = copyOptions.convertField(typeArguments[1], sValue);
|
||||||
|
@@ -50,6 +50,8 @@ public class MapToMapCopier extends AbsCopier<Map, Map> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map copy() {
|
public Map copy() {
|
||||||
|
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
|
||||||
|
|
||||||
this.source.forEach((sKey, sValue) -> {
|
this.source.forEach((sKey, sValue) -> {
|
||||||
if (null == sKey) {
|
if (null == sKey) {
|
||||||
return;
|
return;
|
||||||
@@ -74,7 +76,6 @@ public class MapToMapCopier extends AbsCopier<Map, Map> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 获取目标值真实类型并转换源值
|
// 获取目标值真实类型并转换源值
|
||||||
final Type[] typeArguments = TypeUtil.getTypeArguments(this.targetType);
|
|
||||||
if(null != typeArguments){
|
if(null != typeArguments){
|
||||||
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
|
sValue = this.copyOptions.convertField(typeArguments[1], sValue);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user