I have the following code. I would like to be able to construct the object created in the main method from an XML file. I was thinking about a structure in the form <Main><CustomModel/></Main>
. Is this possible with JAXB and how can I achieve something like this?
@XmlRootElement
public class Main {
private final Model model;
public Main(Model model) {
this.model = model;
}
public static void main(String[] args) {
Main m = new Main(new CustomModel());
}
}
interface Model {};
class CustomModel implements Model {
@XMLElement String test = "1234";
};