Marshal enum
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlRootElement;
public class CardOutput {
public static void main(String[] args) throws JAXBException {
JAXBContext context = JAXBContext.newInstance(Card.class);
context.createMarshaller().marshal(Card.CLUBS, System.out);
}
}
@XmlRootElement
@XmlEnum(String.class)
enum Card {
CLUBS, DIAMONDS, HEARTS, SPADES
}
Related examples in the same category