deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject [4/5] deltaspike git commit: DELTASPIKE-823 refactored duplicate methods handling
Date Sat, 14 Feb 2015 10:19:23 GMT
DELTASPIKE-823 refactored duplicate methods handling

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/812b5548
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/812b5548
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/812b5548

Branch: refs/heads/master
Commit: 812b55487f3cddc641f345575565f368cfca10d7
Parents: 7467b7c
Author: Thomas Andraschko <tandraschko@apache.org>
Authored: Sat Feb 14 11:09:12 2015 +0100
Committer: Thomas Andraschko <tandraschko@apache.org>
Committed: Sat Feb 14 11:09:12 2015 +0100

----------------------------------------------------------------------
 .../impl/PartialBeanProxyFactory.java           | 44 +++++++++++---------
 1 file changed, 24 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/812b5548/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
index ac5e964..5db063b 100644
--- a/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
+++ b/deltaspike/modules/partial-bean/impl/src/main/java/org/apache/deltaspike/partialbean/impl/PartialBeanProxyFactory.java
@@ -90,10 +90,17 @@ public abstract class PartialBeanProxyFactory
      */
     private static Method[] findNotImplementedMethods(Class<?> clazz)
     {
-        List<Method> methods = new ArrayList<Method>(Arrays.asList(clazz.getMethods()));
+        List<Method> methods = new ArrayList<Method>();
         for (Method method : clazz.getDeclaredMethods())
         {
-            if (!methods.contains(method))
+            if (!containsMethodWithSameSignature(method, methods))
+            {
+                methods.add(method);
+            }
+        }
+        for (Method method : clazz.getMethods())
+        {
+            if (!containsMethodWithSameSignature(method, methods))
             {
                 methods.add(method);
             }
@@ -105,16 +112,16 @@ public abstract class PartialBeanProxyFactory
         {
             if (Modifier.isAbstract(currentSuperClass.getModifiers()))
             {
-                for (Method method : currentSuperClass.getMethods())
+                for (Method method : currentSuperClass.getDeclaredMethods())
                 {
-                    if (!methods.contains(method))
+                    if (!containsMethodWithSameSignature(method, methods))
                     {
                         methods.add(method);
                     }
                 }
-                for (Method method : currentSuperClass.getDeclaredMethods())
+                for (Method method : currentSuperClass.getMethods())
                 {
-                    if (!methods.contains(method))
+                    if (!containsMethodWithSameSignature(method, methods))
                     {
                         methods.add(method);
                     }
@@ -172,24 +179,21 @@ public abstract class PartialBeanProxyFactory
 
             currentClass = currentClass.getSuperclass();
         }
-        
-        // sort out method with same signature (see uc008)
-        ArrayList<Method> duplicates = new ArrayList<Method>();
-        for (Method outer : methods)
+
+        return methods.toArray(new Method[methods.size()]);
+    }
+    
+    private static boolean containsMethodWithSameSignature(Method method, List<Method>
methods)
+    {
+        for (Method currentMethod : methods)
         {
-            for (Method inner : methods)
+            if (hasSameSignature(currentMethod, method))
             {
-                if (inner != outer
-                        && hasSameSignature(outer, inner)
-                        && !(duplicates.contains(outer) || duplicates.contains(inner)))
-                {
-                    duplicates.add(inner);
-                }
+                return true;
             }
         }
-        methods.removeAll(duplicates);
-
-        return methods.toArray(new Method[methods.size()]);
+        
+        return false;
     }
     
     private static boolean hasSameSignature(Method a, Method b)


Mime
View raw message