correct downcast from Element to other UML types [message #1848202] |
Wed, 24 November 2021 15:57  |
Eclipse User |
|
|
|
Hi all,
I'm a beginner in Acceleo and I can't find a solution for one template:
I have an "anIssue" UML element of type "InstanceSpecification". From it, several "Dependencies" lead to various elements of different types (Class, Property, UseCase, etc.). I need to list their properties, ie perform a treated downcast.
I downcast to subtypes via oclAsType (). It works for me, but I don't know how to handle the correctness of the downcast before it is called and thus avoid "invalid".
I enclose a statement cycle for Dependency with a note where treatment is missing:
-------------------------------------
[for (dep: uml :: Dependency | anIssue.getClientDependencies ())]
[dep.name /]
[comment Missing correctness handling like "If anIssue.Type is Class" /]
Class:
JAVA name = [dep.target.oclAsType (Class) .name /],
ANALYSIS name = [dep.target.oclAsType (Class) .getLabel () /]
[dep.ownedComment._body /]
[comment Next block for "if anIssue.Type is Property" etc. /]
[/ for]
-----------------------------------
Thanks for concrete advice
Ilya
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04503 seconds