How to use java.util.Optional of a Set with jaxb -


i having issues adapting optional contains set.

initially had set within class marshalled xml such:

@xmlelementwrapper(name = "items") @xmlelement(name = "item") public set<item> getitems() {     return items; } 

we create schema our classes during maven build.however requirement has changed, , set has wrapped in optional still need output schema remain same.

@xmlelementwrapper(name = "items") @xmlelement(name = "item") @xmljavatypeadapter(value = optionaladapter.class) public optional<set<item>> getitem() {     return items; } 

after wrapping set such have created xml adapter:

public class optionaladapter extends xmladapter<set<item>,optional<set<item>>> {     @override      public optional<set<item>> unmarshal(final set<item> v) throws exception      {         return optional.ofnullable(v);      }       @override      public set<item> marshal(final optional<set<item>> v) throws exception      {          return v.orelse(null);      }   } 

after changing classes, schemagen fails (the maven output 'null', far im aware known issue schmemagen).

i have tried changing adapter use collection , remove xmlelementwrapper annotation optional have had no luck. wondering if there else needs taken care of in order generate schema (and marshal/unmarshal) correctly?

many thanks


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -