We have a class with a JAXB annotation on a single property. Then we have several subclasses that annotate the rest of the important data. However, we have one subclass where we want to ignore the annotation of the parent class so that it does not sort. Here is a sample code.
Parent class:
@XmlType(name="Request") @XmlAccessorType(XmlAccessorType.NONE) public abstract class Request { @XmlElement(required=true) private UUID uuid; ... setter/getter }
Now for the subclass:
@Xsd(name="concreteRequest") @XmlRootElement("ConcreteRequest") @XmlType(name="ConcreteRequest") @XmlAccessorType(XmlAccessorType.FIELD) public class ConcreteClass { @XmlElement(required=true) private String data1; @XmlElement(required=true) private String data1; ... setters/getters ... }
When I start an instance of ConcreteClass, I get the following XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ConcreteRequest> <uuid>uuid</uuid> <data1>data</data1> <data2>data</data3> </ConcreteRequest>
Where I want the XML as follows:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ConcreteRequest> <data1>data</data1> <data2>data</data3> </ConcreteRequest>
We have other implementations of the request, but this requires a UUID, this is just a special case. Is there a way to ignore the UUID field in my ConcreteRequest?
marshalling jaxb
prozaak
source share