Derivation expressions
Hans Karlsen (talk | contribs) No edit summary |
(Automatically adding template at the end of the page.) |
||
(4 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
You can derive both attributes and association ends. | You can derive both attributes and association ends. | ||
When it comes to sub-classes that | When it comes to sub-classes that inherit classes that have anything derived, you may want to override the existing derivations. | ||
You do this in the Derivation Expressions tool: | You can do this in the Derivation Expressions tool: | ||
[[File:2020-08-25 15h10 03.png|none|thumb|1045x1045px]] | [[File:2020-08-25 15h10 03.png|none|thumb|1045x1045px]] | ||
Consider this model: | Consider this model: | ||
[[File:2020-08-25 15h13 44.png|none|thumb|615x615px]] | [[File:2020-08-25 15h13 44.png|none|thumb|615x615px]] | ||
The Green side subclasses 2,3 match the pink side subclasses 5,6 | The Green-side subclasses <code>2,3</code> match the pink-side subclasses <code>5,6</code>. It would be good to have a derived association that matches <code>1</code> and <code>4</code> whatever the subclass is. | ||
# Implement the derived link and set the | # Implement the derived link and set the OCL implementation to Class4.nullvalue - it will not be used if your Class1 is abstract. | ||
# On class3 click | # On class3, click on DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class5 (valid since Class5 is a Class4) | ||
# On class2 click | # On class2, click on DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class6 (valid since Class5 is a Class4) | ||
You have now | You have now overridden the dummy default implementation ( Class4.nullvalue) to something valid in the context of the subclass. | ||
[[Category:MDriven Designer]] | |||
{{Edited|July|12|2024}} |
Latest revision as of 15:33, 10 February 2024
You can derive both attributes and association ends.
When it comes to sub-classes that inherit classes that have anything derived, you may want to override the existing derivations.
You can do this in the Derivation Expressions tool:
Consider this model:
The Green-side subclasses 2,3
match the pink-side subclasses 5,6
. It would be good to have a derived association that matches 1
and 4
whatever the subclass is.
- Implement the derived link and set the OCL implementation to Class4.nullvalue - it will not be used if your Class1 is abstract.
- On class3, click on DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class5 (valid since Class5 is a Class4)
- On class2, click on DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class6 (valid since Class5 is a Class4)
You have now overridden the dummy default implementation ( Class4.nullvalue) to something valid in the context of the subclass.
This page was edited more than 11 months ago on 02/10/2024. What links here