JAXB Customizations and List<Object>
I used JAXB to create some classes开发者_StackOverflow社区 from an XSD. The result was not quite what I expected and most probably it can be customized.
It created a generic list instead of 3 different lists. Can this be corrected somehow?
@XmlElements({
@XmlElement(name = "M1", type = M1_Type.class),
@XmlElement(name = "M2", type = M2_Type.class),
@XmlElement(name = "M3", type = M3_Type.class)
})
protected List<Object> m1Orm2OrM3;
Is there a customization to fix this?
You probably have a repeatable choice, something like
<choice maxOccurs="unbounded">
<element name="M1" .../>
<element name="M2" .../>
<element name="M3" .../>
</choice>
The answer is negative, there's no such customization. "Three list" is actually a very different data structure.
精彩评论