JAXB не генерирует подходящие методы получения и установки. Есть только список содержимого<JAXBElement <? >>

Мой JAXB сгенерировал класс Java, как показано ниже:

 <pre>
 * &lt;complexType name="StubCalculationPeriodAmount">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="calculationPeriodDatesReference" type="{http://www.fpml.org/2009/FpML-4-7}CalculationPeriodDatesReference"/>
 *         &lt;choice>
 *           &lt;sequence>
 *             &lt;element name="initialStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue"/>
 *             &lt;element name="finalStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue" minOccurs="0"/>
 *           &lt;/sequence>
 *           &lt;element name="finalStub" type="{http://www.fpml.org/2009/FpML-4-7}StubValue"/>
 *         &lt;/choice>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "StubCalculationPeriodAmount", propOrder = {
    "content"
})
public class StubCalculationPeriodAmount {

    @XmlElementRefs({
        @XmlElementRef(name = "calculationPeriodDatesReference", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class),
        @XmlElementRef(name = "finalStub", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class),
        @XmlElementRef(name = "initialStub", namespace = "http://www.fpml.org/2009/FpML-4-7", type = JAXBElement.class)
    })
    protected List<JAXBElement<?>> content;

    /**
     * Gets the rest of the content model. 
     * 
     * <p>
     * You are getting this "catch-all" property because of the following reason: 
     * The field name "FinalStub" is used by two different parts of a schema. See: 
     * line 14273 of file:/C:/Users/rmei/Eclipse_git_workspace/mlp-fpml/src/main/xsd/fpml-4.7/merged-schema/fpml-main-4-7.xsd
     * line 14267 of file:/C:/Users/rmei/Eclipse_git_workspace/mlp-fpml/src/main/xsd/fpml-4.7/merged-schema/fpml-main-4-7.xsd
     * <p>
     * To get rid of this property, apply a property customization to one 
     * of both of the following declarations to change their names: 
     * Gets the value of the content 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 content property.
     * 
     * <p>
     * For example, to add a new item, do as follows:
     * <pre>
     *    getContent().add(newItem);
     * </pre>
     * 
     * 
     * <p>
     * Objects of the following type(s) are allowed in the list
     * {@link JAXBElement }{@code <}{@link StubValue }{@code >}
     * {@link JAXBElement }{@code <}{@link StubValue }{@code >}
     * {@link JAXBElement }{@code <}{@link CalculationPeriodDatesReference }{@code >}
     * 
     * 
     */
    public List<JAXBElement<?>> getContent() {
        if (content == null) {
            content = new ArrayList<JAXBElement<?>>();
        }
        return this.content;
    }

Этот Java-класс не имеет соответствующего метода получения и установки. Я хочу, чтобы jaxb мог генерировать класс Java, как показано ниже:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "StubCalculationPeriodAmount", propOrder = {
    "calculationPeriodDatesReference",
    "initialStub",
    "finalStub"
})
public class StubCalculationPeriodAmount {

    protected CalculationPeriodDatesReference calculationPeriodDatesReference;
    protected StubValue initialStub;
    protected StubValue finalStub;

    /**
     * Gets the value of the calculationPeriodDatesReference property.
     * 
     * @return
     *     possible object is
     *     {@link CalculationPeriodDatesReference }
     *     
     */
    public CalculationPeriodDatesReference getCalculationPeriodDatesReference() {
        return calculationPeriodDatesReference;
    }

    /**
     * Sets the value of the calculationPeriodDatesReference property.
     * 
     * @param value
     *     allowed object is
     *     {@link CalculationPeriodDatesReference }
     *     
     */
    public void setCalculationPeriodDatesReference(CalculationPeriodDatesReference value) {
        this.calculationPeriodDatesReference = value;
    }

    /**
     * Gets the value of the initialStub property.
     * 
     * @return
     *     possible object is
     *     {@link StubValue }
     *     
     */

Я не уверен, как мне это сделать. Так как этот класс Java генерируется автоматически.

Я хочу получить значение InitialStub, кто-нибудь может мне помочь с этим? Спасибо!

Схема XSD:

</xsd:complexType>
<xsd:complexType name="StubCalculationPeriod">
<xsd:annotation>
<xsd:documentation xml:lang="en">A type describing the Stub Calculation Period.</xsd:documentation>
</xsd:annotation>
<xsd:choice>
<xsd:annotation>
<xsd:documentation xml:lang="en">Choice group between mandatory specification of initial stub and optional specification of final stub, or mandatory final stub.</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="initialStub" type="Stub"/>
<xsd:element name="finalStub" type="Stub" minOccurs="0"/>
</xsd:sequence>
<xsd:element name="finalStub" type="Stub"/>
</xsd:choice>
</xsd:complexType>

0 ответов

Другие вопросы по тегам