现在的位置: 首页 > 综合 > 正文

xsd生成的java对象里的list成员变量没有set函数

2013年01月25日 ⁄ 综合 ⁄ 共 748字 ⁄ 字号 评论关闭

例如:

<xsd:complexType name="Strategy">
        <xsd:sequence>
            <xsd:element name="networks" type="xsd:string" minOccurs="0" maxOccurs="100" />
        </xsd:sequence>
</xsd:complexType>

生成的java对象里只有get函数:

/**
     * Gets the value of the networks property.
     * 
     * <p>
     * This accessor method returns a reference to the live list,
     * not a snapshot. Therefore any modification you make to the
     * returned list will be present inside the JAXB object.
     * This is why there is not a <CODE>set</CODE> method for the networks property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getNetworks().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link Network }
     * 
     * 
     */
    public List<String> getNetworks() {
        if (networks == null) {
            networks = new ArrayList<String>();
        }
        return this.networks;
    }

没有set函数,但是正如get函数的注释所示,使用方法是通过

getNetworks().add(newItem);

抱歉!评论已关闭.