Comment #7 on issue 218 by [email protected]: Assisted inject can't match  
generics parameters correctly
http://code.google.com/p/google-guice/issues/detail?id=218

I just encountered a case where I need this, but the provided solution does  
not suit
me. Here's the use case (with card games, since that's where I found the  
issue).

A typical card game (according to my application) has two or more decks;  
each deck is
composed of exactly one type of cards. The application is generic enough  
not to
decide in the core what composes these decks, and how they are defined.

So my DeckBuilder has this method:

public <C extends Card> Deck<C> buildDeck (Class<C> type);

But to build the deck, I need a provider (or several) in my DeckBuilderImpl.

I've thought about using the MultiBinder (based upon  
Map<Class<?>,Provider<Deck<?>>),
but this is not applicable in my case since so far I can't share the  
multibinder
between all the known modules (the one I develop for the core) and unknown  
ones (the
modules defining the decks). I can't also give a parameter to these  
modules, since 1)
they are unknown 2) they are instanciated via java.util.ServiceLoader.

So, only the generic-parametered factories can help me, but I need the  
genericity on
the method, and not on the factory-type.

I really think that this kind of factory would be needed for modular  
applications
only. Since in all other circumstances I could find a workaround. This is  
the first
time I can't.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to