{"id":6047,"date":"2012-12-24T16:00:45","date_gmt":"2012-12-24T14:00:45","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=6047"},"modified":"2012-12-24T07:00:17","modified_gmt":"2012-12-24T05:00:17","slug":"jaxb-representing-null-and-empty-collections","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html","title":{"rendered":"JAXB &#8211; Representing Null and Empty Collections"},"content":{"rendered":"<h2>Demo Code <\/h2>\n<p>The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an empty list, and the third to a populated list.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<pre class=\" brush:java\">package package blog.xmlelementwrapper;\r\n\r\nimport java.util.ArrayList;\r\nimport javax.xml.bind.*;\r\n\r\npublic class Demo {\r\n\r\n    public static void main(String[] args) throws Exception {\r\n        JAXBContext jc = JAXBContext.newInstance(Root.class);\r\n\r\n        Root root = new Root();\r\n\r\n        root.nullCollection = null;\r\n\r\n        root.emptyCollection = new ArrayList&lt;String&gt;();\r\n\r\n        root.populatedCollection = new ArrayList&lt;String&gt;();\r\n        root.populatedCollection.add('foo');\r\n        root.populatedCollection.add('bar');\r\n\r\n        Marshaller marshaller = jc.createMarshaller();\r\n        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);\r\n        marshaller.marshal(root, System.out);\r\n    }\r\n\r\n}<\/pre>\n<h2>Mapping #1 &#8211; Default <\/h2>\n<p>JAXB models do not require any annotations (see <a href=\"http:\/\/blog.bdoughan.com\/2012\/07\/jaxb-no-annotations-required.html\">JAXB &#8211; No Annotations Required<\/a>). First we will look at what the default behaviour is for collection properties.<\/p>\n<pre class=\" brush:java\">package blog.xmlelementwrapper;\r\n\r\nimport java.util.List;\r\nimport javax.xml.bind.annotation.*;\r\n\r\n@XmlRootElement\r\n@XmlAccessorType(XmlAccessType.FIELD)\r\npublic class Root {\r\n\r\n    List&lt;String&gt; nullCollection;\r\n\r\n    List&lt;String&gt; emptyCollection;\r\n\r\n    List&lt;String&gt; populatedCollection;\r\n\r\n}<\/pre>\n<p>Examining the output we see that the output corresponding to the <em>nullCollection<\/em> and <em>emptyCollection<\/em> fields is the same. This means with the default mapping we can&#8217;t round trip the instance. For the unmarshal use case the value of the <em>nullCollection<\/em> and <em>emptyCollection<\/em> the value of the fields will be whatever the class initialized them to (null in this case).<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:xml\">&lt;?xml version='1.0' encoding='UTF-8'?&gt;\r\n&lt;root&gt;\r\n    &lt;populatedCollection&gt;foo&lt;\/populatedCollection&gt;\r\n    &lt;populatedCollection&gt;bar&lt;\/populatedCollection&gt;\r\n&lt;\/root&gt;<\/pre>\n<h2>Mapping #2 &#8211; @XmlElementWrapper<\/h2>\n<p>The <em>@XmlElementWrapper<\/em> annotation is used to add a grouping element around the contents of a collection. In addition to changing the appearance of the XML representation it also allows us to distinguish between null and empty collections.<\/p>\n<pre class=\" brush:java\">package blog.xmlelementwrapper;\r\n\r\nimport java.util.List;\r\nimport javax.xml.bind.annotation.*;\r\n\r\n@XmlRootElement\r\n@XmlAccessorType(XmlAccessType.FIELD)\r\npublic class Root {\r\n\r\n    @XmlElementWrapper\r\n    List&lt;String&gt; nullCollection;\r\n\r\n    @XmlElementWrapper\r\n    List&lt;String&gt; emptyCollection;\r\n\r\n    @XmlElementWrapper\r\n    List&lt;String&gt; populatedCollection;\r\n\r\n}<\/pre>\n<p>The representation for the null collection remains the same, it is absent from the XML document. For an empty collection we see that only the grouping element is marshalled out. Since the representations for null and empty are different we can round trip this use case.<\/p>\n<pre class=\" brush:xml\">&lt;?xml version='1.0' encoding='UTF-8'?&gt;\r\n&lt;root&gt;\r\n    &lt;emptyCollection\/&gt;\r\n    &lt;populatedCollection&gt;\r\n        &lt;populatedCollection&gt;foo&lt;\/populatedCollection&gt;\r\n        &lt;populatedCollection&gt;bar&lt;\/populatedCollection&gt;\r\n    &lt;\/populatedCollection&gt;\r\n&lt;\/root&gt;<\/pre>\n<h2>Mapping #3 &#8211; @XmlElementWrapper(nillable=true)<\/h2>\n<p>The <em>nillable<\/em> property on the <em>@XmlElementWrapper<\/em> annotation can be used to change the XML representation of null collections.<\/p>\n<pre class=\" brush:java\">package blog.xmlelementwrapper;\r\n\r\nimport java.util.List;\r\nimport javax.xml.bind.annotation.*;\r\n\r\n@XmlRootElement\r\n@XmlAccessorType(XmlAccessType.FIELD)\r\npublic class Root {\r\n\r\n    @XmlElementWrapper(nillable=true)\r\n    List&lt;String&gt; nullCollection;\r\n\r\n    @XmlElementWrapper(nillable=true)\r\n    List&lt;String&gt; emptyCollection;\r\n\r\n    @XmlElementWrapper(nillable=true)\r\n    List&lt;String&gt; populatedCollection;\r\n\r\n}<\/pre>\n<p>Now the grouping element is present for all three fields. The <em>xsi:nil<\/em> attribute is used to indicate that the <em>nullCollection<\/em> field was null. Like the previous mapping this one can be round tripped.<\/p>\n<pre class=\" brush:xml\">&lt;?xml version='1.0' encoding='UTF-8'?&gt;\r\n&lt;root&gt;\r\n    &lt;nullCollection \r\n        xmlns:xsi='http:\/\/www.w3.org\/2001\/XMLSchema-instance'\r\n        xsi:nil='true'\/&gt;\r\n    &lt;emptyCollection\/&gt;\r\n    &lt;populatedCollection&gt;\r\n        &lt;populatedCollection&gt;foo&lt;\/populatedCollection&gt;\r\n        &lt;populatedCollection&gt;bar&lt;\/populatedCollection&gt;\r\n    &lt;\/populatedCollection&gt;\r\n&lt;\/root&gt;<\/pre>\n<p>&nbsp;<\/p>\n<p><strong><em>Reference: <\/em><\/strong><a href=\"http:\/\/blog.bdoughan.com\/2012\/12\/jaxb-representing-null-and-empty.html\">JAXB &#8211; Representing Null and Empty Collections<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Blaise Doughan at the <a href=\"http:\/\/blog.bdoughan.com\/\">Java XML &amp; JSON Binding<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an empty list, and the third to a populated list. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; package package blog.xmlelementwrapper; import java.util.ArrayList; import javax.xml.bind.*; public class Demo { &hellip;<\/p>\n","protected":false},"author":51,"featured_media":112,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[144,107],"class_list":["post-6047","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-jaxb","tag-xml"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JAXB - Representing Null and Empty Collections<\/title>\n<meta name=\"description\" content=\"Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JAXB - Representing Null and Empty Collections\" \/>\n<meta property=\"og:description\" content=\"Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2012-12-24T14:00:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Blaise Doughan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/bdoughan\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Blaise Doughan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html\"},\"author\":{\"name\":\"Blaise Doughan\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/aa63986b9b274cb85d2c6ea9d73bfda8\"},\"headline\":\"JAXB &#8211; Representing Null and Empty Collections\",\"datePublished\":\"2012-12-24T14:00:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html\"},\"wordCount\":306,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"keywords\":[\"JAXB\",\"XML\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html\",\"name\":\"JAXB - Representing Null and Empty Collections\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"datePublished\":\"2012-12-24T14:00:45+00:00\",\"description\":\"Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/enterprise-java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"java-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/12\\\/jaxb-representing-null-and-empty-collections.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"JAXB &#8211; Representing Null and Empty Collections\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/aa63986b9b274cb85d2c6ea9d73bfda8\",\"name\":\"Blaise Doughan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/375230a428542e375a6e404b30a2d5620afc3aadb16e21d1268227def78b3703?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/375230a428542e375a6e404b30a2d5620afc3aadb16e21d1268227def78b3703?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/375230a428542e375a6e404b30a2d5620afc3aadb16e21d1268227def78b3703?s=96&d=mm&r=g\",\"caption\":\"Blaise Doughan\"},\"description\":\"Team lead for the TopLink\\\/EclipseLink JAXB &amp; SDO implementations, and the Oracle representative on those specifications.\",\"sameAs\":[\"http:\\\/\\\/blog.bdoughan.com\\\/\",\"http:\\\/\\\/ca.linkedin.com\\\/in\\\/bdoughan\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/bdoughan\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/blaise-doughan\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JAXB - Representing Null and Empty Collections","description":"Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html","og_locale":"en_US","og_type":"article","og_title":"JAXB - Representing Null and Empty Collections","og_description":"Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an","og_url":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-12-24T14:00:45+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","type":"image\/jpeg"}],"author":"Blaise Doughan","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/bdoughan","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Blaise Doughan","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html"},"author":{"name":"Blaise Doughan","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/aa63986b9b274cb85d2c6ea9d73bfda8"},"headline":"JAXB &#8211; Representing Null and Empty Collections","datePublished":"2012-12-24T14:00:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html"},"wordCount":306,"commentCount":1,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","keywords":["JAXB","XML"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html","url":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html","name":"JAXB - Representing Null and Empty Collections","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","datePublished":"2012-12-24T14:00:45+00:00","description":"Demo Code The following demo code will be used for all the different versions of the Java model. It simply sets one collection to null, the second to an","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/enterprise-java-logo.jpg","width":150,"height":150,"caption":"java-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/12\/jaxb-representing-null-and-empty-collections.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"JAXB &#8211; Representing Null and Empty Collections"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/aa63986b9b274cb85d2c6ea9d73bfda8","name":"Blaise Doughan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/375230a428542e375a6e404b30a2d5620afc3aadb16e21d1268227def78b3703?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/375230a428542e375a6e404b30a2d5620afc3aadb16e21d1268227def78b3703?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/375230a428542e375a6e404b30a2d5620afc3aadb16e21d1268227def78b3703?s=96&d=mm&r=g","caption":"Blaise Doughan"},"description":"Team lead for the TopLink\/EclipseLink JAXB &amp; SDO implementations, and the Oracle representative on those specifications.","sameAs":["http:\/\/blog.bdoughan.com\/","http:\/\/ca.linkedin.com\/in\/bdoughan","https:\/\/x.com\/http:\/\/twitter.com\/bdoughan"],"url":"https:\/\/www.javacodegeeks.com\/author\/blaise-doughan"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/6047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/51"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=6047"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/6047\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/112"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=6047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=6047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=6047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}