Re: Object Constraint Language and Inheritance



Hi,
Ulrich Frank <franku@xxxxxxxxxxxxxxxxx> schrieb:

Namely I have an UML class diagram with an inheritance hierarchie. The
root class is RootClass. For another class, say A, I want to express,
that it is not allowed to have subclasses. My first approach was to use
the ocl method allSupertypes() to forbid subclasses, but in that case I
would have to write it in every class which means I would have to place
it in the RootClass and from there it would be inherited to all other
classes.

if I understand your description correctly, then (caution, neither
type-checked nor proven :-)):

context A
inv: self.allInstancesOf()->forall(c | c.oclIsTypeOf(A))

should do what you want. Nevertheless, the semantics of
oclIsTypeOf() vs. oclIsKindOf() is not that obvious in the standard...

Achim
.