In Papyrus, I try to use the element StateInvariant in a sequence diagram.
When I add a StateInvariant to a lifeline, I can then change the field "Invariant" in the properties view and add a constraint. Well. What I would do is different: I would connect the StateInvariant to a State (of the object represented by the lifeline). I can't find a such feature or how to do that cleanly in Papyrus.
Is it possible? Or I maybe missuse the StateInvariant element?
Have I to create a constraint to check the state of the object represented by the lifeline? In this case, could you give me an example, please?
(If someone can explain StateInvariant to me, I'd be interested).
IMHO, some UML author didn't understand the secret flexibility underlying the lack of specification for Constraints and so duplicated the functionality of a Constraint on a State with a StateInvariant. Both are probably the same, but of course very dependent on what particular tools actually implement, If you want Eclipse OCL support, use Constraint.
As I understand it, the StateInvariant doesn't pertain particularly to States but rather is an invariant constraint on the state (in the abstract sense) of the object represented by the interaction lifeline, its attributes and such. The constraint that it specifies can be expressed in any way that you need. In your case, for example, the standard OCL operation oclIsInState(State) : Boolean may help if you formulate your constraint with OCL.
If your work leads to a simple example that demonstrates the utility of constraints on States, please share it with this newsgroup and I will try to ensure that Eclipse OCL supports it usefully and continues to do so by embedding it as a regression test.