@@ -56,7 +56,7 @@ public static void deepCopy(Object source, Object target) {
56
56
} else if (target instanceof StringBuilder ) {
57
57
((StringBuilder ) target ).append (source );
58
58
} else if (target != null ) {
59
- copy (source , target , ObjUtils :: checkTypeClone );
59
+ copy (source , target , true );
60
60
}
61
61
}
62
62
@@ -71,16 +71,16 @@ public static void shallowCopy(Object sourceObj, Object targetObj) {
71
71
} else if (targetObj instanceof StringBuilder ) {
72
72
((StringBuilder ) targetObj ).append (sourceObj );
73
73
} else if (targetObj != null ) {
74
- copy (sourceObj , targetObj , v -> v );
74
+ copy (sourceObj , targetObj , false );
75
75
}
76
76
}
77
77
78
78
/**
79
79
* 复制对象
80
80
*
81
- * @param fun 值传播方式
81
+ * @param deep 是否对值进行深度克隆
82
82
*/
83
- private static void copy (Object sourceObj , Object targetObj , Function < Object , Object > fun ) {
83
+ private static void copy (Object sourceObj , Object targetObj , boolean deep ) {
84
84
Map <String , Field > a = getFieldMapping (sourceObj .getClass ());
85
85
Map <String , Field > b = getFieldMapping (targetObj .getClass ());
86
86
Map <String , Field > targetF ;
@@ -100,7 +100,7 @@ private static void copy(Object sourceObj, Object targetObj, Function<Object, Ob
100
100
if (sourceField != null ) {
101
101
try {
102
102
Object value = sourceField .get (sourceObj );
103
- targetField .set (targetObj , fun . apply (value )); // 深/浅 克隆关键在于内容的钻取判断
103
+ targetField .set (targetObj , deep ? checkTypeClone (value ) : value ); // 深/浅 克隆关键在于内容的钻取判断
104
104
} catch (IllegalAccessException e ) {
105
105
//
106
106
}
0 commit comments