Pārlūkot izejas kodu

更新重写mybatis的类的代码

miemie 6 gadi atpakaļ
vecāks
revīzija
b9125d1fd0

+ 1 - 11
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/override/MybatisMapperProxy.java

@@ -24,7 +24,6 @@ import java.lang.invoke.MethodHandles;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
 import java.util.Map;
 
 /**
@@ -52,7 +51,7 @@ public class MybatisMapperProxy<T> implements InvocationHandler, Serializable {
         try {
             if (Object.class.equals(method.getDeclaringClass())) {
                 return method.invoke(this, args);
-            } else if (isDefaultMethod(method)) {
+            } else if (method.isDefault()) {
                 return invokeDefaultMethod(proxy, method, args);
             }
         } catch (Throwable t) {
@@ -80,13 +79,4 @@ public class MybatisMapperProxy<T> implements InvocationHandler, Serializable {
                     | MethodHandles.Lookup.PACKAGE | MethodHandles.Lookup.PUBLIC)
             .unreflectSpecial(method, declaringClass).bindTo(proxy).invokeWithArguments(args);
     }
-
-    /**
-     * Backport of java.lang.reflect.Method#isDefault()
-     */
-    private boolean isDefaultMethod(Method method) {
-        return (method.getModifiers()
-            & (Modifier.ABSTRACT | Modifier.PUBLIC | Modifier.STATIC)) == Modifier.PUBLIC
-            && method.getDeclaringClass().isInterface();
-    }
 }

+ 2 - 4
mybatis-plus-core/src/main/java/com/baomidou/mybatisplus/core/override/MybatisMapperProxyFactory.java

@@ -15,6 +15,7 @@
  */
 package com.baomidou.mybatisplus.core.override;
 
+import lombok.Getter;
 import org.apache.ibatis.binding.MapperProxyFactory;
 import org.apache.ibatis.session.SqlSession;
 
@@ -32,6 +33,7 @@ import java.util.concurrent.ConcurrentHashMap;
  */
 public class MybatisMapperProxyFactory<T> {
 
+    @Getter
     private final Class<T> mapperInterface;
     private final Map<Method, MybatisMapperMethod> methodCache = new ConcurrentHashMap<>();
 
@@ -39,10 +41,6 @@ public class MybatisMapperProxyFactory<T> {
         this.mapperInterface = mapperInterface;
     }
 
-    public Class<T> getMapperInterface() {
-        return mapperInterface;
-    }
-
     public Map<Method, MybatisMapperMethod> getMethodCache() {
         return methodCache;
     }