I have several complex data structures like
Map< A, Set< B > >
Set< Map< A, B > >
Set< Map< A, Set< B > > >
Map<
I've solved the problem without XmlAdapter's.
I've written JAXB-annotated objects for Map, Map.Entry and Collection.
The main idea is inside the method xmlizeNestedStructure(...):
Take a look at the code:
public final class Adapters {
private Adapters() {
}
public static Class>[] getXmlClasses() {
return new Class>[]{
XMap.class, XEntry.class, XCollection.class, XCount.class
};
}
public static Object xmlizeNestedStructure(Object input) {
if (input instanceof Map, ?>) {
return xmlizeNestedMap((Map, ?>) input);
}
if (input instanceof Collection>) {
return xmlizeNestedCollection((Collection>) input);
}
return input; // non-special object, return as is
}
public static XMap, ?> xmlizeNestedMap(Map, ?> input) {
XMap
It works!
Let's look at a demo output:
Sorry, the demo output uses also a data structure called "count" which is not mentioned in the Adapter's source code.
BTW: does anyone know how to remove all these annoying and (in my case) unnecessary xsi:type attributes?