pdvrieze / xmlutil

XML Serialization library for Kotlin
https://pdvrieze.github.io/xmlutil/
Apache License 2.0
377 stars 30 forks source link

@XmlClassDiscriminator #181

Closed mgroth0 closed 1 year ago

mgroth0 commented 1 year ago

@JsonClassDiscriminator allows for a custom type discriminator for one type hierarchy. Is there an equivalent feature for Xml? If not, I suggest it.

pdvrieze commented 1 year ago

This is supported through the policy. For the default policy you can set it using the typeDiscriminatorName property. The general case is the polymorphicDiscriminatorName function that allows this to be specified per item. This can be implemented in any way to determine the discriminator to use, including an annotation.