There is a similar question here.
Is it possible, to just unmarshall by providing Person.class
and the unmarshaller finds out itself, whether it has to unmarshall to ReceiverPerson.class
or SenderPerson.class
?
@XmlRootElement(name="person")
public class ReceiverPerson extends Person {
// receiver specific code
}
@XmlRootElement(name="person")
public class SenderPerson extends Person {
// sender specific code (if any)
}
// note: no @XmlRootElement here
public class Person {
// data model + jaxb annotations here
}