Details
-
Type: Bug
-
Status: Closed
-
Priority: Minor
-
Resolution: Not A Bug
-
Affects Version/s: 1.4.2
-
Fix Version/s: Upcoming
-
Component/s: Annotations
-
Labels:None
-
JDK version and platform:Oracle 1.6.0_30 for Windows
Description
When I specify itemFieldName and keyFieldName in @XStreamImplicit annotation, key field is not saved to xml:
with @XStreamImplicit
<test>
<entry>
<string>v1</string>
<string>abc</string>
</entry>
</test>
with @XStreamImplicit(keyFieldName="key", itemFieldName="item")
<test>
<item>abc</item>
</test>
Also, @XStreamImplicit is not equivalent to XStream.addImplicit... methods as it lacks parameters from it's variants.
Also, XStream.addImplicitMap lacks parameter to specify keyType (as is possible to specify itemType).
Sorry, but there's nothing to fix. You can use an implicit map only, if the values contain their key (see Javadoc for keyFieldName) i.e. one of the values' field is used for its key in the map. The implicit map feature explicitly drops the key, because it is redundant for the use case. The types you've used in your example misses this relation. Therefore nothing properly can be generated. For further questions on the topic, please use the user's list.