0
是否有可能绑定Dinice在Guice的泛型类型?Guice类型文字绑定
我知道是否有可能,例如做:
bind(new TypeLiteral<SomeInterface<String>>(){})
.to(SomeImplementation.class);
但是,可以dinamically创建TypeLiteral ??? 。我想在这个例子中,我知道要SomeInterface到SomeImplementation .....但是如果我想要这样做dinamically ...
例如,如果我有String1,String2,....字符串“n”...有可能做类似这样的伪代码的功能
function (Class<?> interfaceWithoutType, Clas<?> type , Class<?> implementingClass) {
TypeLiteral typeLiteral = **"createTypeLiteral"** (interfaceWithoutType, type);
bind (typeLiteral).to(implementingClass)
}
是否有可能做出类似的事情,也许与Refections? 谢谢。