How do I annotate a class that extends a HashMap for XML Marshalling using JAXB.
This example code
@XmlAccessorType(XmlAccessType.FIELD)
public class ExampleMap extends HashMap<String,String>{
public String group= "Test Group";
}
Produces this xml
<ExampleMap>
<group>Test Group</group>
</ExampleMap>
I can modify the class to this
@XmlAccessorType(XmlAccessType.FIELD)
public class ExampleMap extends HashMap<String,String>{
public String group= "Test Group";
public Map<String,String> self = this;
}
and I now get
<ExampleMap>
<group>Test Group</group>
<self>
<entry><key>2</key><value>2</value></entry>
<entry><key>1</key><value>1</value></entry>
</self>
</ExampleMap>
Which is the result I want, but using that self referencing Map<String,String> self = this;
feels wrong.
How should it be done?