简体   繁体   English

使用标签属性过滤简单框架中的标签

[英]Using tag attributes for filtering tags in simple-framework

Now I have this code: 现在我有这段代码:

@ElementListUnion({
        @ElementList(entry = "broom", type = Broom.class, inline = true),
        @ElementList(entry = "update", type = Update.class, inline = true)
})
private List<Task> tasks;

With this code I can write in xml these tags: 通过此代码,我可以在xml中编写这些标签:

<broom/>
<update/>

and different classes for this tags will be used. 并且将使用此标签的不同类。

Now I want to write this xml: 现在,我要编写此xml:

<entry name="broom"/>
<entry name="update"/>

Is it possible to change my annotations, so for these two tags will be used to different classes? 是否可以更改我的注释,所以对于这两个标记将用于不同的类?

Is it possible to change my annotations, so for these two tags will be used to different classes? 是否可以更改我的注释,所以对于这两个标记将用于不同的类?

This is not possible, but with a Converter you can solve this. 这是不可能的,但是使用Converter可以解决此问题。

There you can implement the "if attribute is XY, then ..." part. 在那里,您可以实现“如果属性为XY,则...”部分。

Please see here: 请看这里:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM