• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Curly Generics Question - Update
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Curly Generics Question - Update


  • Subject: Re: Curly Generics Question - Update
  • From: Jim Kinsey <email@hidden>
  • Date: Fri, 15 May 2009 13:56:15 +0100

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@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Curly Generics Question - Update
      • From: Mike Schrag <email@hidden>
References: 
 >Curly Generics Question (From: Andrew Lindesay <email@hidden>)
 >Re: Curly Generics Question - Update (From: Andrew Lindesay <email@hidden>)
 >Re: Curly Generics Question - Update (From: Jim Kinsey <email@hidden>)
 >Re: Curly Generics Question - Update (From: Andrew Lindesay <email@hidden>)

  • Prev by Date: Re: Curly Generics Question - Update
  • Next by Date: Re: Curly Generics Question - Update
  • Previous by thread: Re: Curly Generics Question - Update
  • Next by thread: Re: Curly Generics Question - Update
  • Index(es):
    • Date
    • Thread