JAXB Marshalling and Generics

后端 未结 5 1037
天涯浪人
天涯浪人 2020-12-17 19:29

I am trying to use JAXB\'s introspection to marshall and unmashall some existing domain objects marked up with JAXB annotations. Most things work as expected, but I am havin

5条回答
  •  萌比男神i
    2020-12-17 19:53

    How about

    public class Range<**E extends Number**> implements Serializable { ...
    
    • Number is a class

    • I bet JAXB knows default marshalling/unmarshalling rules for Number

    For unmarshalling to specific type, you need XmlAdapter as I described here: JAXB inheritance, unmarshal to subclass of marshaled class

提交回复
热议问题