Browse Source

修复target错误

zhouhao 6 years ago
parent
commit
a0ef2f2e9b

+ 1 - 1
hsweb-core/src/main/java/org/hswebframework/web/bean/FastBeanCopier.java

@@ -137,7 +137,7 @@ public final class FastBeanCopier {
 
     public static Copier createCopier(Class source, Class target) {
         String sourceName = source.getName();
-        String tartName = source.getName();
+        String tartName = target.getName();
         if (sourceName.startsWith("package ")) {
             sourceName = sourceName.substring("package ".length());
         }

+ 8 - 3
hsweb-core/src/main/java/org/hswebframework/web/proxy/Proxy.java

@@ -15,6 +15,7 @@ import org.springframework.util.ClassUtils;
 import java.util.Arrays;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.Consumer;
 
 /**
  * @author zhouhao
@@ -44,7 +45,6 @@ public class Proxy<I> {
             throw new NullPointerException("superClass can not be null");
         }
         this.superClass = superClass;
-
         ClassPool classPool = new ClassPool(true);
 
         ClassPath classPath = new ClassClassPath(this.getClass());
@@ -85,7 +85,7 @@ public class Proxy<I> {
     }
 
     @SuppressWarnings("all")
-    protected MemberValue createMemberValue(Object value, ConstPool constPool) {
+    public static MemberValue createMemberValue(Object value, ConstPool constPool) {
         MemberValue memberValue = null;
         if (value instanceof Integer) {
             memberValue = new IntegerMemberValue(constPool, ((Integer) value));
@@ -103,12 +103,17 @@ public class Proxy<I> {
             arrayMemberValue.setValue(Arrays.stream(arr)
                     .map(o -> createMemberValue(o, constPool))
                     .toArray(MemberValue[]::new));
-            memberValue=arrayMemberValue;
+            memberValue = arrayMemberValue;
 
         }
         return memberValue;
     }
 
+    public Proxy<I> custom(Consumer<CtClass> ctClassConsumer) {
+        ctClassConsumer.accept(ctClass);
+        return this;
+    }
+
     @SneakyThrows
     public Proxy<I> addField(String code, Class<? extends java.lang.annotation.Annotation> annotation, Map<String, Object> annotationProperties) {
         return handleException(() -> {