uml/ocl access to parent class name

519 views Asked by At

I try to write ocl to add constraint to child (animal), but the constraint must user parent class name (mamifere). I think the first version doesn't work, and I think there is a nicer solution that the second example. Help me please ?

image for example animal:

enter image description here

1

There are 1 answers

0
qwerty_so On

That looks strange. Your first constraint tells (provided it's linked to animal) that the type of aninmal must be mamifere, but mamifere inherits from animal. That does not make sense.

The second variant does not make sense either. Provided the constraint applies to anything on the diagram, each instance must be named mamifere2. So you can have only instances with name == mamifere2. Especially strange with a vivipare2 instance.

I don't see where you model any child relation at all. So I'm just guessing you mean this:

enter image description here

A child has two parents (well, for humans there now can be more). And there can be * children which must have the same type as the parents (so you can't model mules or the like).