Is there a way to specify class type for unmarshalling?

29 Views Asked by At

Assume I have next xml structure:

<someGlobalClass>

  <someType_WithMultipleImpl>
  </someType_WithMultipleImpl>

  <someType_WithMultipleImpl>
  </someType_WithMultipleImpl>

</someGlobalClass>

These two inner tags has similar tag name. But their content is slightly different, so I must implement 2 different classes. During unmarshalling only one implementation of someType_WithMultipleImpl is selected and all other tags are being converted to that single implementation. Is there a way to specify conversion class for XStream? Right now it is something like this

SomeType1:

@XStreamAlias("someType_WithMultipleImpl")
data class SomeType1{
//fields, methods, etc.
}

SomeType2 (that uses same tag name):

@XStreamAlias("someType_WithMultipleImpl")
data class SomeType2(){
//fields, methods, etc.
}

The real example is a bit harder, additional info can be provided if needed

0

There are 0 best solutions below