Search code examples
javasoapenumscxfunmarshalling

Unmarshalling a non mandatory ENUM @XmlElement


I have added some adapters for marshall/unmarshall enums for the XmlRootElement, it worked perfectly, but some of this enum elements can be null, so now, the @XmlJavaTypeAdapter enfonces the unmarshalling no matter if the field is not mandatory. Is there a way to set @XmlJavaTypeAdapter action only when @XmlElement(required = true)?


Solution

  • Can you not just handle null parameters in the unmarshal() and marshal() methods in adapter?