Here's the issue that I have. I have an interface:
public interface MyInterface <AMessageTuple>{
public ConnectableObservable<AMessageTuple> getTokenConnectableObservable();
}
And I have an implementation that I wish to be a singleton:
public class MyImpl implements MyInterface<ImmutablePair<String, Message>> {
...
//irrelevant members omitted
@Override
public ConnectableObservable<ImmutablePair<String, Message>> getTokenConnectableObservable() {
return tokenObservable;
}
...
}
When I try to bind the interface to the implementation in a class that extends Guice's AbstractModule
:
public class MyServiceModule extends AbstractModule {
@Override
protected void configure() {
TypeLiteral <MyInterface<ImmutablePair<String, Message>>> t = new TypeLiteral<MyInterface<ImmutablePair<String,Message>>>() {
};
bind(t).annotatedWith(Names.named("firstOne")).to(MyImpl.class).in(Singleton.class);
}
}
the bind...
ligne gets underlined in red (as compile error) and this is the message I see when hovering over:
The method
bind(Key<T>)
in the typeAbstractModule
is not applicable for the arguments(TypeLiteral<MyInterface<ImmutablePair<String, Message>>>)
The odd thing is that pressing Ctr+Space does recognize that the method bind(TypeLiteral) exists... So am perplexed a bit and hope that someone could give me a hint as to what am I missing.
Context: I am using Eclipse Neon as my IDE, I use (obviously) Guice (version 4.0) for DI and the project's JDK is oracle-7. My current approach on binding generic classes in Guice is based on this question.