如何基于JAXB中的特定条件将<And> </And>标记添加为xml格式?

时间:2019-09-17 10:22:28

标签: jaxb

我正在尝试形成以下XML请求:

<LifecycleConfiguration>
    <Rule>
        <Filter>
            <And>
                <Prefix>key-prefix</Prefix>
                <Tag>
                    <Key>key1</Key>
                    <Value>value1</Value>
                </Tag>
                <Tag>
                    <Key>key2</Key>
                    <Value>value2</Value>
                </Tag>
            </And>
        </Filter>
        <Status>Enabled</Status>
        transition/expiration actions.
    </Rule>
</LifecycleConfiguration>

仅在有多个条目或两个或两个条目都存在的情况下,才应添加标签。

下面是我的过滤器类:-

@XmlRootElement(name = "Filter", namespace = S3Constant.S3_NAMESPACE)
public class LifecycleFilter implements Serializable {


    @XmlElement(name = "Prefix", namespace = S3Constant.S3_NAMESPACE)
    public String prefix;
    /**
     * Objects having the key prefix, to which the rule should apply
     * @valid none
     */

    @XmlElement(name = "Tag", namespace = S3Constant.S3_NAMESPACE)
    public List<Tag> tags;

    public String getPrefix() {
        return (this.prefix);
    }

    public List<Tag> getTagSet() {
        return this.tags;
    }

    public void setTagSet(List<Tag> tags) {
        this.tags = tags;
    }

    public void setPrefix(String prefix) {
        this.prefix = prefix;
    }

    /**
     * Object tags having the key and Value, to which the rule should apply
     * @valid none
     */
}

预先感谢!

0 个答案:

没有答案