是否可以将Environment#registerType
用于java.util.List
或其他集合类型?如果我这样做:
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableGenericTypes();
env.registerType(List.class);
我仍然得到Generic types have been disabled in the ExecutionConfig and type java.util.List is treated as a generic type.
我本来想做的,但由于类型擦除而在 Java 中不可能做到的是:
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableGenericTypes();
env.registerType(List<MyClass>.class);
不幸的是,我在文档中或使用搜索引擎找不到解决方案。
像
这样的实现List<T>
怎么样
class MyClassList implements List<MyClass> {
...
}
然后,您可以使用特定MyClass
注册类型MyClassList