Object Constraint Language and Inheritance



Hallo NG,

I've a problem to express a constraint in OCL. I have already googled
and read in several papers but found no solution which satisfy me.
Perhaps you can help me.
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.

context RootClass
inv: self.allSupertypes() -> forAll(s | s <> A)

Is this right or is there a better way? there is no construct like
allSubclasses(), right?!

Regards,
Uli

.