3
我想通過簡單的框架去序列化XML。我有兩個列表,只有在運行時才知道它們的類型。所以我使用@ElementListUnion。簡單的XML ElementListUnion - 不允許使用兩個通用列表?
Customer.java
@ElementListUnion({@ElementList(inline = true,type=Thing.class),@ElementList(inline = true,type=AnotherThing.class)})
List<Object> things;
@ElementListUnion({@ElementList(inline = true,type=Thing.class),@ElementList(inline = true,type=AnotherThing.class)})
List<Object> anotherthings ;
但是我收到以下異常
03-20 19:36:20.534: E/AndroidRuntime(2764): Caused by:
org.simpleframework.xml.core.PersistenceException: Duplicate annotation of name
'thing' on @org.simpleframework.xml.ElementListUnion(value=
[@org.simpleframework.xml.ElementList(data=false, empty=true, entry=, inline=true,
name=,
required=true, type=class com.data.Thing),
@org.simpleframework.xml.ElementList(data=false,
empty=true, entry=, inline=true, name=, required=true, type=class
com.data.AnotherThing)])
on field 'things' java.util.List com.data.Customer.things
請幫助。