trying to map my class to xml and add custom attributes.
public class MyXmlMappings {
@XmlElement
protected String username;
@XmlElement
protected String password;
@XmlElement
protected Integer age;
}
after marshalling to xml looks like something like this:
<myXmlMappings>
<username/>
<password/>
<age/>
</myXmlMappings>
I need to have xml like this:
<myXmlMappings>
<username type="String" defaultValue="hello" />
<password type="String" defaultValue="asdf" />
<age type="Integer" defaultValue="25" />
</myXmlMappings>
As you can see I added type and defaultValue attributes. How can I add them to myXmlMappings class to be visible after marshalling?
Adding extra fields to myXmlMappings class is not viable I would like to do it somehow with annotations.
XML Representation
I would recommend the following XML representation:
Java Model
With the following Java model:
XmlMappings
XmlMapping