Derivation expressions
Hans Karlsen (talk | contribs) (Created page with "You can derive both attributes and association ends. When it comes to sub-classes that inherits classes that has anything derived you may want to override the existing deriva...") |
Hans Karlsen (talk | contribs) No edit summary |
||
Line 10: | Line 10: | ||
The Green side subclasses 2,3 match the pink side subclasses 5,6 - it would be good to have a derived association that match 1 and 4 whatever the subclass is. | The Green side subclasses 2,3 match the pink side subclasses 5,6 - it would be good to have a derived association that match 1 and 4 whatever the subclass is. | ||
# Implement the derived link and set the ocl implementation to Class4.nullvalue - it is not going to be used if your Class1 is abstract | # Implement the derived link and set the ocl implementation to Class4.nullvalue - it is not going to be used if your Class1 is abstract | ||
# On class3 click up DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class5 | # On class3 click up DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class5 (valid since Class5 is a Class4) | ||
# On class2 click up DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class6 | # On class2 click up DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class6 (valid since Class5 is a Class4) | ||
You have now overriden the dummy defualt implementation ( Class4.nullvalue) to something that is valid in the context of the subclass. | You have now overriden the dummy defualt implementation ( Class4.nullvalue) to something that is valid in the context of the subclass. |
Revision as of 13:20, 25 August 2020
You can derive both attributes and association ends.
When it comes to sub-classes that inherits classes that has anything derived you may want to override the existing derivations.
You 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 match 1 and 4 whatever the subclass is.
- Implement the derived link and set the ocl implementation to Class4.nullvalue - it is not going to be used if your Class1 is abstract
- On class3 click up DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class5 (valid since Class5 is a Class4)
- On class2 click up DerivationExpressions - find the Class4Derived expression - replace it with ocl: self.Class6 (valid since Class5 is a Class4)
You have now overriden the dummy defualt implementation ( Class4.nullvalue) to something that is valid in the context of the subclass.
This page was edited more than 11 months ago on 02/10/2024. What links here