假设您要创建实现如下界面的编辑器LeafValueEditor<int[]>
:
class MyEditor implements LeafValueEditor<int[]> {
@Override
public void setValue(@NotNull int[] value) {
}
@NotNull
@Override
public int[] getValue() {
return new int[0];
}
}
如果您仍在使用 GWT 2.4,上述代码将在运行时使用 NPE 失败
Generator 'com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator' threw an exception while rebinding 'HERE IS YOUR DRIVER CLASS' java.lang.NullPointerException: null
at com.google.gwt.editor.rebind.model.EditorModel.findBeanPropertyMethods(EditorModel.java:509)
at com.google.gwt.editor.rebind.model.EditorModel.createEditorData(EditorModel.java:407)
at com.google.gwt.editor.rebind.model.EditorModel.calculateEditorData(EditorModel.java:345)
at com.google.gwt.editor.rebind.model.EditorModel.<init>(EditorModel.java:237)
在 GWT 2.5 中情况要好一些。编辑器框架只会忽略驱动程序描述中带有此类数组参数的编辑器。为什么 GWT 团队决定忽略这个问题而不是在这个版本中解决它?
我查看了源代码,EditorModel
在这种情况下实现 JArrayType 支持看起来并不难。但这真的很烦人,因为我需要编写样板类来包装数组或使用 java 集合。