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, List<String>> :
Map<String, List<String>> badCast = (Map<String,
List<String>>)headers;
badCast.put("a", new LinkedList<String>());
ms
On May 15, 2009, at 8:56 AM, Jim Kinsey wrote:
Hi Andrew,
what the calling method ought to be doing though is declaring the
list it passes as Map<String, List<String>> 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 in a similar fashion. It's got me. You are
right, I could create a new Map and use that instead as it should
work, but that would be rather inelegant.
I was meaning that as more of an example of why, possibly, the
"bug" (I'm not sure it really can be called that yet) exists - that
there was some calling code somewhere in the WO source which was
passing in something declared a bit too concrete, so it got "fixed"
by wildcarding the List parameter on createRequest rather than
changing the declaration in the calling code to work to an interface.
I think the only real solution which still involves overriding
createRequest is to override without generics and suppress the
warning; if you want to do lots of work within the overridden
createRequest and like to have the generic type checking then you
could pass this work on to a different method with appropriately
generic arguments:
@SuppressWarnings("unchecked")
@Override
public WORequest createRequest(String method, String aurl,
String anHTTPVersion,
Map someHeaders, NSData content,
Map someInfo) {
return genericCreateRequest(method, aurl, anHTTPVersion,
someHeaders, content, someInfo);
}
private WORequest genericCreateRequest(String method, String aurl,
String anHTTPVersion,
Map<String, List<String>> someHeaders, NSData content,
Map<String, Object> someInfo) {
someHeaders.put("foo",
Collections.<String>singletonList("bar"));
return super.createRequest(method, aurl, anHTTPVersion,
someHeaders, content, someInfo);
}
Cheers,
Jim
Could this be considered a bug in WOApplication?
Yes, I think it is not quite right.
cheers.
___
Andrew Lindesay
www.lindesay.co.nz
http://www.bbc.co.uk
This e-mail (and any attachments) is confidential and may contain
personal views which are not the views of the BBC unless
specifically stated.
If you have received it in error, please delete it from your system.
Do not use, copy or disclose the information in any way nor act in
reliance on it and notify the sender immediately.
Please note that the BBC monitors e-mails sent or received.
Further communication will signify your consent to this.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/mschrag%40mdimension.com
This email sent to [email protected]
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com
This email sent to [email protected]