|
@@ -18,9 +18,7 @@
|
|
|
|
|
|
package org.hswebframework.web.commons.entity.factory;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.hswebframework.web.NotFoundException;
|
|
|
import org.hswebframework.utils.ClassUtils;
|
|
|
import org.hswebframework.web.bean.FastBeanCopier;
|
|
@@ -37,9 +35,9 @@ import java.util.function.Supplier;
|
|
|
*/
|
|
|
@SuppressWarnings("unchecked")
|
|
|
public class MapperEntityFactory implements EntityFactory {
|
|
|
- private Map<Class, Mapper> realTypeMapper = new HashMap<>();
|
|
|
- private Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
- private Map<String, PropertyCopier> copierCache = new HashMap<>();
|
|
|
+ private Map<Class, Mapper> realTypeMapper = new HashMap<>();
|
|
|
+ private Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
+ private Map<String, PropertyCopier> copierCache = new HashMap<>();
|
|
|
|
|
|
private static final DefaultMapperFactory DEFAULT_MAPPER_FACTORY = clazz -> {
|
|
|
String simpleClassName = clazz.getPackage().getName().concat(".Simple").concat(clazz.getSimpleName());
|
|
@@ -53,12 +51,6 @@ public class MapperEntityFactory implements EntityFactory {
|
|
|
|
|
|
private static final DefaultPropertyCopier DEFAULT_PROPERTY_COPIER = (source, target) -> {
|
|
|
return FastBeanCopier.copy(source, target);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
};
|
|
|
|
|
|
private DefaultMapperFactory defaultMapperFactory = DEFAULT_MAPPER_FACTORY;
|
|
@@ -128,13 +120,6 @@ public class MapperEntityFactory implements EntityFactory {
|
|
|
|
|
|
if (realType == null) {
|
|
|
mapper = defaultMapperFactory.apply(beanClass);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
if (!Modifier.isInterface(beanClass.getModifiers()) && !Modifier.isAbstract(beanClass.getModifiers())) {
|
|
|
realType = beanClass;
|
|
@@ -203,7 +188,7 @@ public class MapperEntityFactory implements EntityFactory {
|
|
|
}
|
|
|
|
|
|
public static class Mapper<T> {
|
|
|
- Class<T> target;
|
|
|
+ Class<T> target;
|
|
|
Supplier<T> instanceGetter;
|
|
|
|
|
|
public Mapper(Class<T> target, Supplier<T> instanceGetter) {
|
|
@@ -236,12 +221,9 @@ public class MapperEntityFactory implements EntityFactory {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @SneakyThrows
|
|
|
public T get() {
|
|
|
- try {
|
|
|
- return type.newInstance();
|
|
|
- } catch (Exception e) {
|
|
|
- throw new RuntimeException(e);
|
|
|
- }
|
|
|
+ return type.newInstance();
|
|
|
}
|
|
|
}
|
|
|
}
|