Re: Generics and Filtering on a Subclass
Re: Generics and Filtering on a Subclass
- Subject: Re: Generics and Filtering on a Subclass
- From: Mike Schrag <email@hidden>
- Date: Mon, 23 Jun 2008 11:27:15 -0400
Well, this works, but seems like I'm reinventing the wheel.
NSMutableArray<Finished> descendantFinisheds = new NSMutableArray<Finished>();for (Part aPart : descendantParts()) { if (aPart instanceof Finished) { descendantFinisheds.addObject((Finished) aPart); } }
And if I can force the casting of one object, why can't I force the casting of the Array using (NSArray<Finished>) EOQual...?
Filtering with a qualifier is a generic (uh .. not generic like generics) implementation of this filtering, so it's impossible to enforce the rule you're specifying statically. You are going to have to cast somewhere. In your case, you're casting the objects inside the array, but you should be able to cast the resultant array from the original filter also. You may need to specify your original array as NSMutableArray<? extends Part> instead of NSMutableArray<Part>, but regardless you're going to have to cast somewhere in the chain to do this.
ms |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden