Return-Path: X-Original-To: apmail-deltaspike-commits-archive@www.apache.org Delivered-To: apmail-deltaspike-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9B06E10DA0 for ; Sat, 14 Feb 2015 10:19:21 +0000 (UTC) Received: (qmail 20230 invoked by uid 500); 14 Feb 2015 10:19:21 -0000 Delivered-To: apmail-deltaspike-commits-archive@deltaspike.apache.org Received: (qmail 20149 invoked by uid 500); 14 Feb 2015 10:19:21 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 20027 invoked by uid 99); 14 Feb 2015 10:19:21 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2015 10:19:21 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id EB196E0664; Sat, 14 Feb 2015 10:19:20 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tandraschko@apache.org To: commits@deltaspike.apache.org Date: Sat, 14 Feb 2015 10:19:23 -0000 Message-Id: <8722f226f60d4852ae128ec1ddd93aa3@git.apache.org> In-Reply-To: <294f1dbeba124623a6c5a8d58e568771@git.apache.org> References: <294f1dbeba124623a6c5a8d58e568771@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [4/5] deltaspike git commit: DELTASPIKE-823 refactored duplicate methods handling 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 Authored: Sat Feb 14 11:09:12 2015 +0100 Committer: Thomas Andraschko 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 methods = new ArrayList(Arrays.asList(clazz.getMethods())); + List methods = new ArrayList(); 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 duplicates = new ArrayList(); - for (Method outer : methods) + + return methods.toArray(new Method[methods.size()]); + } + + private static boolean containsMethodWithSameSignature(Method method, List 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)