|XJC Customization to have *some* classes extend common Super Class and not implement own body [message #1826084]
||Sat, 18 April 2020 18:41
| Kirill Marchuk
Registered: April 2020
It's the only place I could find where to ask for this (beyond SO, of course)
Anyway, here's the question: I am generating Java classes based on a schema from 3rd party, which defines TENS of identical types, but each of those types is defined as a unique, separate type. So, it generates many operations that will have same signature but will accept different type as request and different type as response:
ResponseA operationA(RequestA request);
ResponseB operationB(RequestB request);
ResponseC operationC(RequestC request);
all those RequestX types are identical. same goes for ResponseX types. Now, I cannot even parametrize those, as neither of those is extending anything. If only they were declared as inheriting same ancestor, that would contain all the "internals" of the type, it would be much simpler.
I googled and found "xjc:superClass" but this
a) works on ALL classes in the schema
b) extends all generated classes some provided class, but does not change anything in the class definitions otherwise.
Is it possible to find another JAXB extension that would allow to me to do the above? Or is it possible to define one? Otherwise, what would be suggested course of action?
currently, I can only think of 3 options (bare the ones highlighted above):
- accept things as they are and just write tons of duplicated code for those models and calls
- commit XJC-generated classes as "regular source code" and update those to fit what I need (which I don't really want to do, as 3rd party might update their schemas occassionally, but probably that's the most appealing option atm)
- implement some rough and tough code generation with something like JavaParser (or, less heavily, just use reflection for mapping)
any suggestions are highly appreciated!
Powered by FUDForum
. Page generated in 0.01903 seconds