Simple Xml Elementlistunion - Two Generic Lists Not Allowed?
I am trying to desrialize an xml through simple framework. I have two lists whose types will be known only at runtime. So I used @ElementListUnion. Customer.java @ElementListUnion
Solution 1:
You haven't set a value for entry
, so Simple can't decide which class you are using. See here:
@Root(name = "Customer")
public class Customer
{
@ElementListUnion(
{
@ElementList(entry = "thingValue", inline = true, type = Thing.class),
@ElementList(entry = "anotherThingValue", inline = true, type = AnotherThing.class)
})
List<Object> things;
@ElementListUnion(
{
@ElementList(entry = "thingValue", inline = true, type = Thing.class),
@ElementList(entry = "anotherThingValue", inline = true, type = AnotherThing.class)
})
List<Object> anotherthings;
}
Each @ElementList
requires an entry
, thats the tag which is used for the element:
<Customer><thingValue>...<thingValue/><!-- That's a 'Thing' --><anotherThingValue>...<anotherThingValue/><!-- That's an 'AnotherThing' --></Customer>
But make shure you dont name the entry
like the class, so entry = "thing"
may fail.
Post a Comment for "Simple Xml Elementlistunion - Two Generic Lists Not Allowed?"