(Adding message template to the top of the page) |
(Updated Edited template to July 12, 2025.) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
<message>Write the content here to display this box</message> | |||
You may define methods in classes and implement these with OCL: | You may define methods in classes and implement these with OCL: | ||
Line 25: | Line 25: | ||
SomeMethodThatReturnsList(myparam:String,SomeOtherParam:Integer,aListOfValue:Collection(SomeClass)):Collection(SomeClass) | SomeMethodThatReturnsList(myparam:String,SomeOtherParam:Integer,aListOfValue:Collection(SomeClass)):Collection(SomeClass) | ||
[[Category:OCL]] | [[Category:OCL]] | ||
{{Edited|July|12| | {{Edited|July|12|2025}} |
Latest revision as of 05:53, 20 January 2025
You may define methods in classes and implement these with OCL:
Do this in the OCL implementation in the Body-property:
Notice that since this was a method, MDriven will treat your OCL as EAL – something that has side effects. In this case, our method does not have any side effects and you may want to be able to use this method in OCL, but trying to use it in OCL will not succeed. Methods with side effects are not recognized by OCL. There is a flag on the Method definition called IsQuery and if this is set, we “promise” that it does not have intentional side effects. Now it is seen by OCL:
We can then use our IsQuery method in any expression in OCL. Thing.allinstances- >select(x|x.MyMethod(x.SomeInt))
Parameters and Return Types
Give parameters and return types in this format:
SomeMethod(myparam:String):String SomeMethod(myparam:String,SomeOtherParam:Integer):String SomeMethod(myparam:String,SomeOtherParam:Integer,aListOfValue:Collection(String)):String SomeMethodThatReturnsList(myparam:String,SomeOtherParam:Integer,aListOfValue:Collection(String)):Collection(String) SomeMethodThatReturnsList(myparam:String,SomeOtherParam:Integer,aListOfValue:Collection(SomeClass)):Collection(SomeClass)