Re: Generics question

2009-05-28 Thread Ricardo J. Parada
you to return any subclass of MPVLoginPage. Bill From: Ricardo J. Parada [mailto:rpar...@mac.com] To: WebObjects-Dev Apple [mailto:webobjects-...@lists.apple.com] Sent: Thu, 28 May 2009 17:00:06 -0600 Subject: Generics question I'm changing my code to use pageWithName(Foo.class) instead

Re: Curly Generics Question - Update

2009-05-16 Thread Q
On 16/05/2009, at 12:07 PM, Mike Schrag wrote: I'm not sure this is really any better ... Fundamentally there's a ? in that param, and as a result, it's impossible to do a put in a typesafe way. You don't know what V is. I _think_ the signature as it is now is actually correct, but if

Re: Curly Generics Question - Update

2009-05-16 Thread Mike Schrag
you should clone it to a concrete mutable type if you wish to modify it. have fun with this btw ... the cherry on top is that you can't even reliably CLONE these stupid things, because 1) cloning in java is retarded and 2) even if you can clone, you might just be cloning an immutable map

Re: Curly Generics Question - Update

2009-05-15 Thread Jim Kinsey
Hi Andrew, I find it odd that the map should have ? extends ListString as a parameter as the extension ought to be unnecessary (assuming callers are working to the List interface) - any List implementation with a String parameter fulfills ListString. I like generics too, but have come

Re: Curly Generics Question - Update

2009-05-15 Thread Andrew Lindesay
Hello Jim; Thanks for the reply. what the calling method ought to be doing though is declaring the list it passes as MapString, ListString and hiding the concrete List implementation, negating the need for the wildcard. I tried it with a concrete implementation of List as well, but this

Re: Curly Generics Question - Update

2009-05-15 Thread Mike Schrag
Yeah this is a tricky one ... But you're right that the API is ? extends ListString so you can pass in NSArrayString, which is a pretty common implementation. You also can't necessarily just assume people can declare their vars as ListString instead of NSArrayString because you don't know

Re: Curly Generics Question - Update

2009-05-15 Thread Jim Kinsey
Hi Andrew, what the calling method ought to be doing though is declaring the list it passes as MapString, ListString and hiding the concrete List implementation, negating the need for the wildcard. I tried it with a concrete implementation of List as well, but this also raised an error

Re: Curly Generics Question - Update

2009-05-15 Thread Mike Schrag
well, no matter what you do, i think you're going to throw out type safety, so inside the method, you could just cast the headers to String, ListString : MapString, ListString badCast = (MapString, ListString)headers; badCast.put(a, new LinkedListString()); ms On May 15, 2009,

Re: Curly Generics Question - Update

2009-05-15 Thread Lachlan Deck
On 15/05/2009, at 10:48 PM, Mike Schrag wrote: Yeah this is a tricky one ... But you're right that the API is ? extends ListString so you can pass in NSArrayString, which is a pretty common implementation. You also can't necessarily just assume people can declare their vars as ListString

Re: Curly Generics Question - Update

2009-05-15 Thread Mike Schrag
public WORequest createRequest( String method, String aurl, String anHttpVersion, Map String, ? extends List String someHeaders, NSData content,

Re: Curly Generics Question - Update

2009-05-15 Thread Mike Schrag
Map String, List String correctHeaders = new HashMap String, List String (); btw, this is what i was saying that the only typesafe way to do this is to copy the original headers -- so you would do new HashMapString, ListString(originalHeaders) and then you'd have a properly typesafe

Re: Curly Generics Question - Update

2009-05-15 Thread Lachlan Deck
On 16/05/2009, at 9:27 AM, Mike Schrag wrote: public WORequest createRequest( String method, String aurl, String anHttpVersion, Map String, ? extends List String someHeaders,

Re: Curly Generics Question - Update

2009-05-15 Thread Chuck Hill
On May 15, 2009, at 4:59 PM, Lachlan Deck wrote: Generics are great mostly - but there are times when it's just downright annoying :-). Sounds like Maven! :-P -- Chuck Hill Senior Consultant / VP Development Come to WOWODC'09 in San Fran this June!

Re: Curly Generics Question - Update

2009-05-15 Thread Lachlan Deck
On 16/05/2009, at 10:03 AM, Chuck Hill wrote: On May 15, 2009, at 4:59 PM, Lachlan Deck wrote: Generics are great mostly - but there are times when it's just downright annoying :-). Sounds like Maven! :-P Touché ;-) But still lovin' your work as the unlikely ambassador, finding every

Re: Curly Generics Question - Update

2009-05-15 Thread Henrique Prange
Hi Mike, The following solution doesn't solve the unchecked type cast problem. But it respect PECS definition and accept a MapString, NSArrayString as parameter. Do you think it is reasonable? public V extends ListString WORequest treateRequest(String method, String url, String

Re: Curly Generics Question - Update

2009-05-15 Thread Mike Schrag
I'm not sure this is really any better ... Fundamentally there's a ? in that param, and as a result, it's impossible to do a put in a typesafe way. You don't know what V is. I _think_ the signature as it is now is actually correct, but if you need to insert into that map inside

Re: Curly Generics Question - Update

2009-05-15 Thread Anjo Krank
Am 16.05.2009 um 01:29 schrieb Mike Schrag: Map String, List String correctHeaders = new HashMap String, List String (); btw, this is what i was saying that the only typesafe way to do this is to copy the original headers -- so you would do new HashMapString,

Curly Generics Question

2009-05-14 Thread Andrew Lindesay
I've been working with generics for quite a while (and quite like them) but this one has me stumped! public WORequest createRequest(String method,String url,String anHTTPVersion,MapString,? extends ListString someHeaders,NSData content,MapString,Object someInfo) { ...

Re: Curly Generics Question - Update

2009-05-14 Thread Andrew Lindesay
Sorry wrong method; I obviously meant put rather than add in this example and The method put(String,ListString) in the type MapString,capture#1-of? extends ListString is not applicable for the arguments (String,ListString) is the problem. I've been working with generics for quite a while

Generics Question

2007-12-20 Thread Jonathan Miller
Hi, Will someone please help me here? How do I do the following without getting the pesky warning from Eclipse about unchecked type conversion? NSArrayNewsKeywords newsKeywords = EOUtilities .objectsForEntityNamed (EOSharedEditingContext.defaultSharedEditingContext(), NewsKeywords);

Re: Generics Question

2007-12-20 Thread Art Isbell
On Dec 20, 2007, at 2:03 PM, Jonathan Miller wrote: How do I do the following without getting the pesky warning from Eclipse about unchecked type conversion? NSArrayNewsKeywords newsKeywords = EOUtilities .objectsForEntityNamed (EOSharedEditingContext.defaultSharedEditingContext(),