Search code examples
umlocl

Count the occurrences of a boolean operation


I have to make an OCL rule saying that two parameters cannot be equal. I cannot use the not() so I have to show that something like param1 = param2 is empty.

I tried to use isEmpty() and size() but as it's boolean, these operators don't work

self.ab1.ab2
->forAll(x | x.b1.b2
->forAll(port | (self.param1 = port.param2)->isEmpty())

 )

I think I have to use some kind of count() operator that needs to be equal to 0 to show that param1 and param2 are different but I don't know how to use it.

Thank you for your help


Solution

  • For your direct question, use of <> and so self.param1 <> port.param2 would seem appropriate. However doing a doubly nested forAll starting in some context seems unhelpful. If you cannot move the 'constraint' to a better context perhaps you can at least be clearer by: self.ab1.ab2.b1.b2.param2->asSet()->excludes(self.param2)