I am trying to create a jaxb class hierarchy for a web services domain. It’s inconvenient for me that a subclass that overrides the getter method in the superclass can change the name of the element that JAXB returns, but the superclass alone is also written to the output. I am wondering if there is a way to suppress a getter in a superclass.
code:
@XmlType class SuperClass { @XmlElement(name = "Name") public String getName(){} } @XmlType class SubClass extends SuperClass { @Override @XmlElement(name = "CoolName") public String getName(){} }
When I add a SubClass element to XmlRootElement, the XML output contains two elements, <Name> and <CoolName>. Is there any way to suppress <Name> being marshaled?
source share