Can one change/influence JAXB's code generation? -
I was wondering if a JAXB XML schema (.xsd) could affect the "style" of code generated from fles is. Like I would like to:
-
Emits a comment within the newly generated sections, especially if the class is empty because it creates warnings in my environment.
-
Change all the setter-methods to return the object instead of "zero" so that one can do the call-chaining:
X some method () {Return new X (). SetFoo (5) .setBar ("Some"); }
Instead of tireless:
X some method () {xx = new (x); X.setFoo (5); X.setBar ("something"); Return x; }
Is there a few "templates" anywhere that uses JAXB and who can make more changes to achieve such things? Or is it all that hard-coded?
M.
There is no template to modify generated code easily.
However, for example many plugins: that you want according to your 2 bullets.
There are other plugins, e.g. For comments suppressing warnings - which can help against bullets first.
As an additional, I would like to mention that Java classes are not being made with XML Schema, but with handwriting (most comments,) is an alternative option, provided that the XML schema is very complex is not. In addition to solving # 1 and # 2, there may be other benefits.
Comments
Post a Comment