提交 cd15316f 作者: 方治民

feat: 优化 Commons.transform null 对象时快速返回

上级 d34a0722
......@@ -96,6 +96,10 @@ public class Commons {
*/
public <T> T transform(Object source, Class<T> type, String... ignoreProperties) {
try {
if (source == null) {
return null;
}
Constructor<T> declaredConstructor = type.getDeclaredConstructor();
// 实例化
T target = declaredConstructor.newInstance();
......@@ -138,6 +142,10 @@ public class Commons {
CallbackFunction<S, T> fn,
String... ignoreProperties
) {
if (!notEmpty(list)) {
return Collections.emptyList();
}
try {
Constructor<T> declaredConstructor = type.getDeclaredConstructor();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论