Return-Path: X-Original-To: apmail-ant-notifications-archive@minotaur.apache.org Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 197EF9B73 for ; Mon, 5 Mar 2012 20:42:37 +0000 (UTC) Received: (qmail 7009 invoked by uid 500); 5 Mar 2012 20:42:36 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 6967 invoked by uid 500); 5 Mar 2012 20:42:36 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 6959 invoked by uid 99); 5 Mar 2012 20:42:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 20:42:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.115] (HELO eir.zones.apache.org) (140.211.11.115) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Mar 2012 20:42:35 +0000 Received: by eir.zones.apache.org (Postfix, from userid 80) id 2C0232AA7; Mon, 5 Mar 2012 20:42:15 +0000 (UTC) From: bugzilla@apache.org To: notifications@ant.apache.org Subject: DO NOT REPLY [Bug 52829] implement Iterable interface in FileSet and others Date: Mon, 05 Mar 2012 20:42:14 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ant X-Bugzilla-Component: Core X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: jglick@netbeans.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: notifications@ant.apache.org X-Bugzilla-Target-Milestone: 1.9.0 X-Bugzilla-Changed-Fields: CC Message-ID: In-Reply-To: References: X-Bugzilla-URL: https://issues.apache.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-Virus-Checked: Checked by ClamAV on apache.org https://issues.apache.org/bugzilla/show_bug.cgi?id=52829 Jesse Glick changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jglick@netbeans.org --- Comment #1 from Jesse Glick 2012-03-05 20:42:14 UTC --- Such types should indeed implement Iterable. The question is what the type parameter should be. In the case of ResourceCollection, probably the parameter should be Resource. Now if this were actually "? extends Resource" then FileSet could override this to be an Iterable, or ResourceCollection could even itself take a type parameter describing the subtype of Resource it contains, but I am not sure we want to get this complicated with generics - it can be rather tricky to understand such code and make it work correctly with extensions. Probably simpler and better would be to leverage the Resource.as method and do not allow covariant Resource subtypes. Then FileResource can continue to be an implementation detail, which FileSet and friends would not be obliged to use, and your client code would do something like: for (Resource r : someFileSetOrOtherResourceCollection) { File f = r.as(FileProvider.class).getFile(); // ... } which extends naturally to other extension interfaces like URLProvider. I believe this works in Rhino JavaScript as well (just omit the ".class" on the type token and of course qualify it if needed). Of course if you are unsure what the collection might consist of, you must check each call to as(FileProvider) for a null return value. There could also be convenience methods somewhere (Resource? Resources? Files?) such as /** call {@link Resource#as} on each element, throw NPE or similar if missing */ public static

Iterable

as(ResourceCollection rc, Class

type); /** obtains {@link FileProvider} from each element; must be filesystemOnly */ public static Iterable asFiles(ResourceCollection rc); to simplify loops. -- Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the assignee for the bug.