Can XmlJavaTypeAdapter marshal from ClassA object to ClassB object? So that when :
public void createClassB (ClassB b) { }
I can pass in ClassA object. Does it possible?
Can XmlJavaTypeAdapter marshal from ClassA object to ClassB object? So that when :
public void createClassB (ClassB b) { }
I can pass in ClassA object. Does it possible?
Yes it can, but not quite like this. I mean you can not pass a ClassA
object, where ClassB
is required, unless ClassA
is a sub-class of ClassB
. Read through this example, its showing how you can marshal a Currency
object as a String
into your XML. So, quiet similar to the example, you should be able to marshal ClassA object to ClassB or something.
A little different solution, which is odd, and which you probably aren't looking for, but anyway:
ClassA
in the JAXB ContextClassB
in the JAXB Context