Gwt 使用GIN注入ListEditor的泛型工厂

Gwt 使用GIN注入ListEditor的泛型工厂,gwt,generics,guice,gwt-gin,gwt-editors,Gwt,Generics,Guice,Gwt Gin,Gwt Editors,我编写了一个工厂,可以创建任何类型的ListEditor: public interface ListEditorFactory<T, E extends Editor<T>> { ListEditor<T, E> create(InsertPanel panel); } 我尝试了bind(newtypeliteral>(){})但是有一个 java.lang.IllegalArgumentException: Expected a Class, P

我编写了一个工厂,可以创建任何类型的ListEditor:

public interface ListEditorFactory<T, E extends Editor<T>> {
    ListEditor<T, E> create(InsertPanel panel);
}
我尝试了
bind(newtypeliteral>(){})但是有一个

java.lang.IllegalArgumentException: Expected a Class, ParameterizedType, or GenericArrayType, but <?> is of type com.google.inject.internal.MoreTypes$WildcardTypeImpl
java.lang.IllegalArgumentException:应为类、ParameterizedType或GenericArrayType,但类型为com.google.inject.internal.MoreTypes$WildcardTypeImpl
绑定
bind(newtypeliteral(){}).to(newtypeliteral(){})正在运行,但通用工厂失去了很多兴趣

您知道声明此绑定的一般方法吗


谢谢

我设法找到了一个解决方案,摆脱了
ListEditorFactory
接口,不再需要在gin模块中声明绑定

我可以直接注入实现,没有任何问题:

@Inject
protected void init(ListEditorFactoryImpl<NoteDTO, CharacterNoteScreen> listEditorFactory) {
    notesEditor = listEditorFactory.create(notePanel);
@Inject
受保护的void init(ListEditorFactoryImpl listEditorFactory){
notesEditor=listEditorFactory.create(notePanel);
如果gin能够注入这个,我认为它没有理由不能通过接口注入它,而是错误的绑定声明

因此,即使我对我的解决方案感到满意,我还是把问题放在一边,因为这可能是一种声明绑定的方法。

根据Gin的说法,它不能用通配符类型注入泛型,因为它在编译时完成所有工作,而有效类型未知。我仍然不理解没有绑定声明时它是如何工作的,我认为有同样的问题。无论如何,我接受这个答案,因为似乎没有更好的解决办法。
@Inject
protected void init(ListEditorFactory<NoteDTO, CharacterNoteScreen> listEditorFactory) {
    notesEditor = listEditorFactory.create(notePanel);
[ERROR] Generator 'com.google.gwt.inject.rebind.GinjectorGenerator' threw an exception while rebinding 'net.test.client.MyGinjector'
com.google.inject.ConfigurationException: Guice configuration errors:
1) javax.inject.Provider<E> cannot be used as a key; It is not fully specified.
java.lang.IllegalArgumentException: Expected a Class, ParameterizedType, or GenericArrayType, but <?> is of type com.google.inject.internal.MoreTypes$WildcardTypeImpl
@Inject
protected void init(ListEditorFactoryImpl<NoteDTO, CharacterNoteScreen> listEditorFactory) {
    notesEditor = listEditorFactory.create(notePanel);