[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.gmt] Re: OAW - Type Casting with XTend

Yes of course they are not in the same hierarchy, that's why I indeed need the cast!
Just assume e.role is a Property, which is a ConnectableElement as well as MultiplicityElement.


Best Regards
Alexander Nyßen


"Karsten Thoms" <karsten.thoms@xxxxxxxxx> schrieb im Newsbeitrag news:g3qkt1$njg$1@xxxxxxxxxxxxxxxxxxxx
Hi Alexander,

you get this error because those types are not in a type hierarchy and cannot be casted therefore.

The type hierarchy is as follows:

Element <- NamedElement <- TypedElement <- ConnectableElement
Element <- MultiplicityElement

You may consult the UML2 superstructure. Seems that the ConnactableElement's role is not an MultiplicityElement.

~Karsten

Alexander Nyßen schrieb:
I have specified the following in my Extension:

cached int getConnectorCount(uml::ConnectorEnd e) :
uml::MultiplicityElement.isInstance(e.role) ?
e.getPartWithPortMultiplicity() * e.upper() * ((uml::MultiplicityElement)e.role).upper()
: e.getPartWithPortMultiplicity() * e.upper()
;


The cast of e.role into MultiplicityElemenet is acknowledged by the OAW environement with the error "cannot cast from uml::ConnectableElement into uml::MultiplicityElement". The dynamic type of e.role may however by a MultiplicityElement. What am I doing wrong?