Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.2.1
-
Fix Version/s: None
-
Component/s: Core
-
Labels:None
Description
When I convert a TreeSet into a XML the XStream put the comparator field.
I tried to force the omit field:
xs.omitField(TreeSet.class, "comparator");
No success.
VELO
Hi Marvin,
unfortunately most of the stuff for tweaking the XML does only work for the generic converters that are based on reflection. For the TreeSet XStream delivers a custom converter that writes content in synthetic tags i.e. those tags have nothing to do with the real names of the fields within a class. TreeSet is part of the JDK and every vendor can use an own name for the field keeping the Comparator (and they do) and XStream.omitField cannot help you, since you have to provide the declaring class and the name of the field. This is why XStream's own TreeSetConverters does not support this functionality.
To solve your problem and to get rid of the comparator element, you may simply register for the TreeSet a "standard" CollectionConverter that does not know anything about the availability of such an element: