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 A957A114EF for ; Mon, 2 Jun 2014 07:00:07 +0000 (UTC) Received: (qmail 56811 invoked by uid 500); 2 Jun 2014 07:00:07 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 56710 invoked by uid 500); 2 Jun 2014 07:00:07 -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 56699 invoked by uid 99); 2 Jun 2014 07:00:07 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 Jun 2014 07:00:07 +0000 Date: Mon, 2 Jun 2014 07:00:07 +0000 (UTC) From: "Thomas Neidhart (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (COLLECTIONS-530) Rejecting items on predicate failure without throwing an Exception 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-530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14015212#comment-14015212 ] Thomas Neidhart commented on COLLECTIONS-530: --------------------------------------------- I like the idea, something like this could be added imo. We should discuss this first on the mailinglist to get feedback also from other people. > Rejecting items on predicate failure without throwing an Exception > ------------------------------------------------------------------ > > Key: COLLECTIONS-530 > URL: https://issues.apache.org/jira/browse/COLLECTIONS-530 > Project: Commons Collections > Issue Type: Improvement > Components: List > Affects Versions: 4.0 > Reporter: Erik > > The PredicatedList class doesn't allow entries that fail the predicate, but throws an Exception on entry. > The problem I have with this, is that it places the onus of filtering out invalid entries on the caller. > I typically add items in a loop. The item added is the result of a method call (which returns null if it can't create one). > This problem is so common for me that I have created my own FilteredList class that simply ignores invalid entries. > I would like the PredicatedList class to be capable of rejecting items without throwing an exception. > I don't mind writing the code for this, but there are a great many ways in which this can be done. > So I was wondering what the interface should look like. > Separate FilteredList class. > Works, but seems a little verbose for the purpose > New factory method: filteredList(List list, Predicate predicate) > Nice and simple, but doesn't allow extension; other ways of dealing with predicate failure. > New factory method with enum: predicatedList(List list, Predicate predicate, PredicateFailEnum action) > More verbose to use and adds an extra class, but allows more alternative ways to deal with predicate failure. > One more nice thing is that it might be less confusing, > because choosing between predicatedList and the above filteredList might not be so obvious. > New factory method with interface: filteredList(List list, Predicate predicate, PredicateFailInterface action) > Complex, but the most flexible way of dealing with predicate failure. -- This message was sent by Atlassian JIRA (v6.2#6252)