Hi,
I can't figure out how to bind class parametrized with a given Class?
For example if I have something like this:
Module createModule(Class clazz, List list) {
return new AbstractModule() {
protected void configure() {
bind(??????).toInstance(list);
}
};
}
then after this call: createModule(String.class, new ArrayList())
I have binding from List<String> to my list
This binding should be equivalent to this one: bind(new
TypeLiteral<List<String>>() {}).toInstance(list);
I tried to the following, but compiler does not like it and I am not really
sure this is the right way:
bind(Key.get(Types.newParameterizedType(List.class,
clazz))).toInstance(list);
Thanks!
--
Dmitry Skavish
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---