Skip to content

Commit

Permalink
2.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sim-wangyan committed Nov 14, 2023
1 parent b29602f commit cb0786f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions sqli-core/src/main/java/io/xream/sqli/converter/X2Bean.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
*/
package io.xream.sqli.converter;

import io.xream.sqli.util.SqliJsonUtil;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -47,10 +50,14 @@ public static <T> T copy(Class<T> clz, Map<String, Object> map) {
}
filedList.addAll(Arrays.asList(clz.getDeclaredFields()));

if (clz.isRecord()) {
return SqliJsonUtil.toObject(map,clz);
}

T obj = null;
try {
obj = clz.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
obj = clz.getDeclaredConstructor().newInstance();
} catch (Exception e) {
throw new UnsupportedOperationException(e);
}

Expand Down

0 comments on commit cb0786f

Please sign in to comment.