So I'm using BeanIO and I have to write a type handler, which will assigned null to list if the generic list is empty. For example I'm importing addresses from xml file.
If there is full information about address, xml looks like this:
<Address>
<Street1>aaaaaa</Street1>
<PostCode>00-000</PostCode>
<City>bbbbb</City>
<CountryCode>AA</CountryCode>
<PhoneNo>+00 00 00000000</PhoneNo>
<Email>aaa@aaa.aaa</Email>
</Address>
If there is no informations of address in xml file, it looks like this:
<Address />
Mapping in java class looks like this - with BeanIO @segment annotation:
@Segment(xmlName = "Address", minOccurs = 0, maxOccurs = -1)
private List<Address> address;
Basically, the test class expects that if above list is empty, the type handler should assign null to it. Without any type handler for the list, the empty brackets are assigned:
address=[]
And here is my question, does anyone know how the handler should looks for Collections types, in this case List? Previously I wrote some handlers for strings, ints and so on - things with @Field annotation and everything work well. Now I'm struggling to write for the things with @Segment annotations. Any hints? From which class to inherit from?