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 createRequest, you simply have to copy it. I don't think it's possible to ensure compiler-enforceable type-safety in any other way (which is to say, "accurate type safety").

ms

On May 15, 2009, at 9:51 PM, Henrique Prange wrote:

Hi Mike,

The following solution doesn't solve the unchecked type cast problem. But it respect PECS definition and accept a Map<String, NSArray<String>> as parameter. Do you think it is reasonable?

public <V extends List<String> > WORequest treateRequest(String method, String url, String anHTTPVersion, Map<String, ? super V> someHeaders, NSData content, Map<String, Object> someInfo) {
  ...
  someHeaders.put("foo", (V) Collections.singletonList("bar"));
  ...
}

Cheers,

Henrique

On May 15, 2009, at 8:29 PM, Mike Schrag wrote:

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 HashMap<String, List<String>>(originalHeaders) and then you'd have a properly typesafe <String, List<String>> that you can happily insert into whatever List<String> subtypes you want inside of createRequest. But it takes a copy to do it, which kind of sucks.

ms

_______________________________________________
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/hprange%40gmail.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/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]

Reply via email to