|Multiple inheritance (from PackageableElement) and issues regarding the generated code [message #628112]
||Tue, 08 December 2009 09:25
| Cristian Mising name
Registered: July 2009
I have a custom metamodel that extends the UML2 metamodel.
I have a class Base that extends Element.
I have a class PackageableBase that extends Base and PackageableElement (in this order).
The generated PackageableBaseImpl extends BaseImpl. Because of the multiple inheritance, EMF generates inside my PackageableBaseImpl class:
* fields (and getters + setters) that are specific to PackageableElement: name, visibility, clientDependencies, etc. Until now everything is OK.
* eBaseStructuralFeatureID() that converts featureIDs from superclasses to featureIDs
Until now, everything is OK.
The only problem comes from the VISIBILITY field. In fact, the eGet, eSet ... family doesn't contain a proper CASE in its SWITCH (it does from all the other fields such as NAME, CLIENT_DEPENDENCY, etc). Because of this, when one of this methods is invoked with the VISIBILITY field (during COPY, or SAVE), the call is not properly managed, ending up with a NullPointerException.
I see in uml.ecore that PackageableElement has a "duplicates" annotation containing the "visibility" field, and perhaps this is related to my problem.
Perhaps there is an option during the UML-EMF conversion, or something else that could be specified to enforce the "correct" generation (as I wouldn't like to suppress the generated tag and modify the above methods (eSet, eIsSet, etc)).
Thank you in advance,
PS: I see that if my Base class extends from NamedElement instead of Element, I have no more problems.
But I cannot understand exactly why. Is it because the "visibility" field declared in PackageableElement "redefines" the "visibility" field declared in NamedElement, so when a class extends PackageableElement it should extend NamedElement as well?
Powered by FUDForum
. Page generated in 0.01489 seconds