Open mkotelba opened 9 years ago
You're right, property name creation is hardcoded at the moment:
After taking a stab at it, I must admit that the guts of XJC are tricky as hell; I have a new-found appreciation for the Simplify plugin :)
I tried to approach the functionality by adding a new Simplify-specific customization element, generated-property, that can be used multiple times in the same context as the relevant Simplify as-*-property, each time providing an association of a property local name that naturally gets spit out by Simplify -> what you actually want it to be called.
Once you get down to the correct CPropertyInfo, its easy (2x calls to setName for the public/private variants). Dealing with the crazy complexity of all possible combinations to get there (CReferencePropertyInfo, CElementPropertyInfo, etc combos) + possible Java keyword conflicts that result in forced renames and even more abstraction = I gave up and wrote a terrible Groovy GMaven build script that just iterates through the ClassOutlines' properties.
@mkotelba Sorry to hear about this. I actually did not thought it was so complex. I'd personally add a configuration sub-element like
<simplify:as-element-property>
<simplify:property element="foo:bar" name="bar"/>
</simplify:as-element-property>
The XML element names should be quite easy to get from items of CElementPropertyInfo
or CReferencePropertyInfo
. So find out the QName
of the element and look up the customized property name for it in the customization.
CTypeRef.getTagName()
provides the QName).CElement.getElementName()
provides the QName).So I think this must be doable.
What were you trying to do, exactly? Would you give an example of your desired customization?
@highsource there are news about property name customization?
No, not yet. PRs welcome - as always.
Unless I'm mistaken, there is currently no mechanism to customize the name of the Java properties outputted by the Simply plugin, aside from the pluralization option; I half-remember seeing a statement somewhere in the docs (perhaps the old ones on highsource.org?) to this effect.
If this is indeed the case, should I be aware of anything in particular if I were to fork and (attempt to) implement the functionality?