java - JAXB - Binding element to Set instead of List -


is there way make jaxb generate collection set instead of list defined element?

for example generating set of books xsd:

<xs:element name="collection"> <xs:complextype>   <xs:sequence>     <xs:element name ="books">        <xs:complextype>           <xs:sequence>             <xs:element name="book" type="booktype" minoccurs="1" maxoccurs="unbounded"/>           </xs:sequence>        </xs:complextype>     </xs:element>   </xs:sequence> 

when using following bindings.xml

<jxb:bindings schemalocation="schema.xsd">     <jxb:bindings node="//xs:element[@name='shop']/xs:complextype/xs:sequence/xs:element[@name='books']">         <jxb:property collectiontype="java.util.hashset" />     </jxb:bindings> </jxb:bindings> 

a list of books concret hashset implementation generated:

list<book> books = new hashset<book>(); 

i don't think can done custom binding, because according guide on customizing jaxb bindings:

collectiontype defines customization value propertycollectiontype, collection type property. propertycollectiontype if specified, can either indexed or fully-qualified class name implements java.util.list.

however, might possible if wrote own xjc plugin. take @ following article see how: writing plug-in jaxb ri easy


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -