-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inheritance Plugin Question #513
Comments
I think this was by design since (not sure but if not it should) you could define 2 or more interface for the same base class with the inheritance plugin. Moreover, you could downcast by calling methods with interface signature ( The goal of inheritance plugin is to give you ability to specify a special base class (extends) or base interface (implements) in generated code from xjc maven-plugin. |
@mattrpav could you confirm ? |
@laurentschoelens I can confirm that it is doeing what you described. If intention is to have only a e.g. abstract base class or interface for a class (or all classes) that works fine (and is the way I used in the past). Nevertheless, now I stumbled over the case I described above. No need to have two interfaces implemented. But rather the need to have the specified interface used throughout the references of a class everywhere within the generated code (e.g. ObjectFactory and Classes referencing the class with Interface instead of classname...) |
@laurentschoelens @SebasHein XSD has a gap in the spec where there is not a way to define an 'interface' type concept.
The inheritance plugin allows you to apply existing interfaces to model classes or define classes to extend. To replace return types on a xjc generated class, you'd need to do the following:
|
Ok thanks |
If it's a need, it could be somewhat a new feature of the plugin ? |
I try to let two generated classes implement their own interface.
Example
Class A should implement IA
Class B should implement IB
This is working so far (wiht XInheritance plugin) as long as class A and B are implementing their interfaces.
But the interfaces are not used:
e.g. the object factory returns on createA and createB methods A / B classes instead of IA and IB.
Even worse:
If class A holds a List of type B then the created get method is
public List getBs instead of public List getBs.
Is there a way to achieve this?
Or is XInheritance in general only focusing on the class specified in the bindings file and not taken care of the references to the given class?
For me and my current situation: I can work around this because B is not necessarily forced to implement IB.
But it would be nicer to work on interfaces everywhere possilbe so I wanted to ask and clarify.
If this is not possible at the moment then just tell me and close the issue.
The text was updated successfully, but these errors were encountered: