java - JAXB Marshalling and Generics -


I am trying to use martial to use the introspection of JSSB and some existing domain objects have JAXB annotations Is marked with. Most things work as expected, but I am getting a fairly simple class to serialize. This class is used as a XML number of @mail as a number of beans and looks like something:

  public class category & lt; E comparative & lt; E & gt; & Gt; Serializable {secure boolean initial implementation, inherent; Safe e start, end; Public Range () {startInclusive = endInclusive = True; } Public boolean includes (e-value) {...} public e-mail () {end of return; } Public Zero Set-End (E End) {this.end = end; } The public boolean is the end () {Return endInclusive; } Public Zero SetIndecal (Boolean Endline) {this.endInclusive = endInclusive; } Public e getStart () {start start; } Public Zero Set Start (e Start) {this.start = start; } Public boolean is StartInclin () {Return Start Index; } Public Zero SettyIntual (Boolean StartInclinic) {this.startInclusive = startInclusive; }}  

I have tried to do the following, without any success, JAASAB still gets annoyed with the interface.

  increases the public square DoubleRange range & lt; Double & gt; {}  

Using Range and DoubleRange both as returns for the yield of Bean Geestra is an exception:

 java.lang.Comparable is an interface, And JAXB handle interface This problem is related to the following location: java.lang. Equivalent to protected java.lang.Compatible as com.controlpath.util.Range.start example. Small. Example. Example.util.DoubleRange on public examples. Red.DoubleLarge Example.domain.SomeBean.getRange () For example. Domains. A little bit 

I know that in most cases the list & lt; T & gt; More Maps & lt; T, U & gt; Only work because there are special provisions for those types of JACB specifications, when they come on beans, but is there any way to tell that the JAGB introspection engine is able to complete the boundary with non-normal areas What to do?

You can write a custom adapter (not using the JAASB's XML Adapter):

1) Announce a class that is all type And JAXB holds annotations and handles them according to your wishes (in my example, I change everything in a string)

  @YourJAXBnnotationsGoHere public class MyAdapter {@XmlElement / / @ XML Attribute if you want personal string content; Public MyAdapter (object input) {if (input examples of string) {content = (string) input; } And if (ExampleFinder's example yourFavoriteClass) {content = ((YourFavoriteClass) input) .convertSomehowToString (); } And if (examples of input .......) {content = ((.....) input) .convertSomehowToString (); // and so on} and {content = input.toString (); }}} // I have a map & lt; Classroom & lt ;? & Gt ;, imiobjetosting converter & gt; 

>

  • Definitely not no for complex (nested) data structures Will work.
  • You have to think about how to reopen this back, it can be more difficult. If this is very difficult, then I think wait for a better proposal;)

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -