シンプルなフレームワークを使用して xml を逆シリアル化しようとしています。実行時にのみ型がわかる 2 つのリストがあります。そこで、@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
助けてください。