I am a bit lost trying to bind generic classes.
Consider the following pseudo classes:
class Store {
void persist(Entity)
Adapter getAdapter(Entity)
}
class AStore: Store
class BStore: Store
class Entity
class XEntity: Entity
class YEntity: Entity
class Adapter
class AXAdapter: Adapter
class AYAdapter: Adapter
class BXAdapter: Adapter
class BYAdapter: Adapter
How could I use Guice to implement a factory for adapters? I basically
want to call Store.persist(Entity) and have the Store base class get
the right adapter for the specific Store and the specific Entity. So,
for instance, AStore.getAdapter(XEntity) should return AXAdapter. It
is as if I could bind <Store,Entity> to a given adapter
implementation. Of course, it would be ideal if I could have a generic
implementation of the code instead of having to duplicate the code for
each Store subclass.
I went as far as using injector.getBindingsByType() but the code
always returns nothing. Wondering if this is a supported usecase and
if others had implemented such Many-to-Many bindings before.
thanks in advance.
--
You received this message because you are subscribed to the Google Groups
"google-guice" 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?hl=en.