我有以下路线:
from("direct:abc")
// read the file
.split(body().tokenize("\n", 3, false)).streaming().stopOnException()
.unmarshal(new BindyCsvDataFormat(Foo.class))
.process(new FooListProcessor());
问题是,如果我在文件中有 4 条记录,则第一组作为处理器进入,List
而第二组作为单个Foo
对象进入。instanceof
每次发生这种情况时,我都必须检查正文并创建一个列表。
Foo
班级:
@CsvRecord(separator = ",")
public class Foo {
@DataField(pos = 1)
private String fooField;
@DataField(pos = 2, trim = true)
private String barField;
}
文件内容:
"lorem","ipsum"
"dolorem","sit"
"consectetur","adipiscing"
"eiusmod","incididunt"
有没有办法强制Bindy
总是解组为 a List
?