简体   繁体   中英

JaxB : Define default @XmlElements for a specific data type

As shown below JaxB provides for children to be differentiated by the tag name.

@XmlElements({
    @XmlElement(name="horse", type=Horse.class),
    @XmlElement(name="cow", type=Cow.class)
})
private Animal animal;

But how can I implement the desired functionality by default. Every Animal within the document should have the choice of Horse or Cow but I don't want to type the @XmlElements every time ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM