0
我试图绑定具有泛型参数的具体类。 如:使用Guice的Genric /匿名类型注入
public class Concrete<T> extends GenericClass<T, Employee>{
public Employee method(T input){
//Do stuff
}
}
现在我的其他类使用这个具体类的多个对象 如:
public class UseConcrete{
private Concrete<Class1> concrete1;
private Concrete<Class2> concrete2;
@Inject
publicUseConcrete(Concrete<Class1> concrete1,Concrete<Class2> concrete2){
this.concrete1 = concrete1;
this.concrete2 = concrete2;
}
}
我想知道如果这样的简单绑定将工作?我会尝试这个,但只是想看看我是否在错误的轨道上。
bind(Concrete.class);
我的UseConcrete是我想要注入Concrete类的类。这是我在UseConcrete的构造函数中所做的。这会起作用吗? – user41191