xsd - How to generate JaxB-Classes with java.util.Optional? -


i use jaxb2-maven-plugin generate jaxb-classes given xsd. works fine. want use java.util.optional in generated classes. jaxb generated classes without optionals. i'm forced make null-check of every variable.

did know how jaxb2-maven-plugin has configured use java.util.optional?

thanks help!

maybe find more generic i'm not sure if possible. anyway can still define custom adapter types want optional.

here example of integer

first, create adapter

public final class integeroptionaladapter extends optionaladapter<integer> { }  

then use adapter in binding

@xmlattribute @xmljavatypeadapter(integeroptionaladapter.class) private optional<integer> someinteger; 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -