Following your advice (Thanx!) i changed the findButler method:
private Butler<Person> findButler(Person person, Injector injector){
Class<? extends Person> personClass = person.getClass();
ParameterizedType parameterizedButler =
Types.newParameterizedType(Butler.class,
personClass);
Key<?> key = Key.get(parameterizedButler);
Butler<Person> butler = (Butler<Person>) injector.getInstance(key);
return butler;
}
But now I'm getting an IllegalArgumentException that i don't
understand:
java.lang.IllegalArgumentException: No owner type for enclosed
interface test.com.jaculon.core.guice.GuiceInjectServiceTest$Butler
at
com.google.inject.internal.Preconditions.checkArgument(Preconditions.java:
113)
at com.google.inject.internal.MoreTypes
$ParameterizedTypeImpl.<init>(MoreTypes.java:476)
at
com.google.inject.util.Types.newParameterizedTypeWithOwner(Types.java:
60)
at com.google.inject.util.Types.newParameterizedType(Types.java:49)
at
test.com.jaculon.core.guice.GuiceInjectServiceTest.findButler(GuiceInjectServiceTest.java:
84)
at
test.com.jaculon.core.guice.GuiceInjectServiceTest.testGetInstance(GuiceInjectServiceTest.java:
76)
Any Ideas?
On 5 Nov., 14:08, Esko Luontola <[email protected]> wrote:
> You should be able to use the Types.newParameterizedType method, like
> this:
>
> https://github.com/orfjackal/dimdwarf/blob/83e6dadb48841b7bd3532580a0...
--
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.