| Author |
Proper Generic Syntax for a Nested Collection of Objects on a method Parameter
|
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
I have a method defined in an Interface that returns a Question:
The pseudo implementation uses generics to indicate the AsyncCallbak will return a Question:
public void saveQuestion(Question question, AsyncCallback<Question> callback);
I have another method that returns a List of Question objects:
How do I indicate that the AsynchCallback is returning a List of Questions, List<Question>.
The following will fail, because I have only genericized the List, not the List<Question>.
public void getAllQuestions(AsyncCallback<List> callback);
Essentially, I have a container containing a container containing a container. So, I need to genericize 'two deep.'
I don't want to just use <List>, but I want to indicate that it's a List<Question>. What's the syntax?
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
Sitting here, talking it out, I decided to try something:
Man, that syntax looks awful. No possible way that should work, right?
Go figure?
-Cameron McKenzie
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
You mean this?
|
 |
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Joined: Aug 26, 2006
Posts: 4967
|
|
Thanks Paul. I knew I'd have an answer before I had time to get a pop from the fridge.
Back to work...
|
 |
 |
|
|
subject: Proper Generic Syntax for a Nested Collection of Objects on a method Parameter
|
|
|