Is it possible, using the BeanIO annotations, to define a field as a collection of an abstract class, or a collection of classes implementing an interface?
What I want is this:
@Record(minOccurs = 1, maxOccurs = -1, collection = List.class)
List<SomeInterface> records;
I then supply a list of different concrete classes to the collection, which all contains all the annotations for defining a valid record.
However I just get an error saying
Repeating segments without any child field component must have minOccurs=maxOccurs
...which kind of defeats the purpose.
Some things I have tried:
- Setting the stream to writeOnly
- Using an abstract class instead of an interface
EDIT: This is my configuration:
StreamFactory factory = StreamFactory.newInstance();
StreamBuilder builder = new StreamBuilder("MyStreamName")
.writeOnly()
.format("delimited")
.parser(new DelimitedParserBuilder(','))
.addGroup(Parent.class);
factory.define(builder);
...whereas the Parent.class contains the List<SomeInterface> records;
Logically, there should be something tying the SomeInterface to the concrete implementations of the interface so that BeanIO could figure out what to do, but I can't seem to figure out how to set up this connection.