Lets say I have a generic class as follows:
public class Base<T extends Stoppable> {
protected final Injector injector;
protected T stoppable;
public Base(Module... module) {
injector = Guice.createInjector(module);
Key<T> key = Key.get(new TypeLiteral<T>() {}); <-- T cannot be used as a key; It is not fully specified.
stoppable = injector.getInstance(key);
}
}
The instance of type Stoppable is binded using Multibinder:
Multibinder<Stoppable> taskBinder =
Multibinder.newSetBinder(binder, Stoppable.class);
taskBinder.addBinding().to(MyClass.class);
Is it possible to achieve this?