我有这样的 XSD 架构:
<xs:complexType name="Element" abstract="true">
<xs:sequence maxOccurs="unbounded">
<xs:element name="resistor" type="vs:Resistor" maxOccurs="unbounded"/>
<xs:element name="capacitor" type="vs:Capacitor" maxOccurs="unbounded"/>
<xs:element name="inductor" type="vs:Inductor" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
当我通过 JAXB 处理这个模式时,我得到一个像这样的字段:
@XmlElements({
@XmlElement(name = "resistor", required = true, type = Resistor.class),
@XmlElement(name = "capacitor", required = true, type = Capacitor.class),
@XmlElement(name = "inductor", required = true, type = Inductor.class)
})
protected List<Object> resistorAndCapacitorAndInductor;
但我想得到
protected List<Resistor> resisitors;
protected List<Capacitor> capacitors;
protected List<Inductor> inductors;
这个怎么做?