Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 83857105D5 for ; Fri, 26 Dec 2014 13:30:13 +0000 (UTC) Received: (qmail 5109 invoked by uid 500); 26 Dec 2014 13:30:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 5012 invoked by uid 500); 26 Dec 2014 13:30:13 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 4999 invoked by uid 99); 26 Dec 2014 13:30:13 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Dec 2014 13:30:13 +0000 Date: Fri, 26 Dec 2014 13:30:13 +0000 (UTC) From: "Thomas Neidhart (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COLLECTIONS-537) PredicateUtils (all|any)Predicate type misbehaviour Array vs. Collection MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/COLLECTIONS-537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14259075#comment-14259075 ] Thomas Neidhart commented on COLLECTIONS-537: --------------------------------------------- Yes indeed, the correct signature should be: {code} Predicate anyPredicate(final Collection> predicates) {code} This change will require some more changes in other places too for sake of consistency. The test case to demonstrate the change: {code} import java.util.ArrayList; import java.util.List; import org.apache.commons.collections4.Predicate; import org.apache.commons.collections4.PredicateUtils; public class MyTest { public static class A { int val; public A(int val) { this.val = val; } public String toString() { return "A"; } } public static class B extends A { public B(int val) { super(val); } public String toString() { return "B"; } } public static class MyPredicate implements Predicate { private int eval; public MyPredicate(int eval) { this.eval = eval; } @Override public boolean evaluate(A object) { return object.val < eval; } } public static void main(String[] args) { MyPredicate p1 = new MyPredicate(10); MyPredicate p2 = new MyPredicate(20); Predicate anyPredicate = PredicateUtils.anyPredicate(p1, p2); System.out.println(anyPredicate.evaluate(new B(10))); List> list = new ArrayList>(); list.add(p1); list.add(p2); Predicate anyPredicate2 = PredicateUtils.anyPredicate(list); System.out.println(anyPredicate2.evaluate(new B(10))); } } {code} > PredicateUtils (all|any)Predicate type misbehaviour Array vs. Collection > ------------------------------------------------------------------------ > > Key: COLLECTIONS-537 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-537 > Project: Commons Collections > Issue Type: Bug > Components: Functor > Affects Versions: 4.0 > Reporter: Frank Jakop > > Migrating from collections-generic to collections4 we encountered a type problem with PredicateUtils. When you look at the method anyPredicate(), the signature with array is typed with "Predicate" whereas the signature with Collection is typed "? extends Predicate", so the both methods are not equivalent. > We think both methods should have the same types, so it would not break compatibility with a lot of legacy code. -- This message was sent by Atlassian JIRA (v6.3.4#6332)