Gewünschtes Ergebnis:
Einfacher Wechsel zwischenCode: Select all
..
..
Code: Select all
..
..
..
..
Mein Code
Root.javaCode: Select all
@XmlRootElement(name= "root")
public class Root {
@XmlElement(name="child")
public Child child
}
Code: Select all
@XmlRootElement(name= "root")
public class ExtendedRoot extends Root {
@XmlElement(name="child")
public ExtendedChild child
}
Code: Select all
@XmlTransient
public class Child {
// prop1, prop2
}
Code: Select all
@XmlType(propOrder = {"prop1", "prop3","prop4", "prop2"})
public class ExtendedChild extends Child {
// prop3, prop4
}
Main
Code: Select all
System.setProperty("javax.xml.bind.context.factory", "org.eclipse.persistence.jaxb.JAXBContextFactory")
Class clazz = extendChild ? ExtendedRoot.class : Root.class;
JAXBContext jc = JAXBContext.newInstance(clazz);
Marshaller marshaller = jc.createMarshaller();
marshaller.marshal(formattedJob, tempFile);
Code: Select all
..
..
..
..