I have the following route:
from("direct:abc")
// read the file
.split(body().tokenize("\n", 3, false)).streaming().stopOnException()
.unmarshal(new BindyCsvDataFormat(Foo.class))
.process(new FooListProcessor());
The problem is that if I have 4 records in file first group comes in processor as List
but the second as a single Foo
object.
I have to check body with instanceof
and create a list every time when such cases occurs.
Foo
class:
@CsvRecord(separator = ",")
public class Foo {
@DataField(pos = 1)
private String fooField;
@DataField(pos = 2, trim = true)
private String barField;
}
File content:
"lorem","ipsum"
"dolorem","sit"
"consectetur","adipiscing"
"eiusmod","incididunt"
Is there a way to force Bindy
to always unmarshall into a List
?
No bindy returns a single instance if there is single instance. And a list of there are more.
I have logged a ticket for an improvement so you can configure this: https://issues.apache.org/jira/browse/CAMEL-12321