JAXB plugin to generate Bean Validation Annotations (JSR-303)
I did this plugin myself to map xs:restrictions to the objects generated by the XJC compiler.
What it does:
-It generates @valid annotation for objects that are not in the xs default schema (so annotations are cascaded)
-It generates @NotNull annotation for objects that has a MinOccur value >= 1 or for attributes with required use
-It generates @Size for lists that have minOccurs > 1
-It generates @Size if there is a maxLength or minLength restriction
-@DecimalMax for maxInclusive restriction
-@DecimalMin for minInclusive restriction
-@Digits if there is a totalDigits or fractionDigits restriction.
-@Pattern if there is a Pattern restriction
Please note that minExclusive and maxExclusive restrictions are excluded.
To use it, you have to package the class file along a META-INF/services/com.sun.tools.xjc.Plugin file with the content "com.sun.tools.xjc.addon.jaxb.JaxbValidationsPlugins" (that is, the fully qualified name of the class) and call XJC with the -XValidate switch.
It's not really difficult to implement, but I hope it will be useful for someone. The source code is attached as a TXT file. Enjoy!