Documentation of OCL-Schemata
Composite_isLayeredGraph.ocl
Invariant
let subtypes=OclType.allInstances->select(c|c.allSupertypes->includes(Composite)) in
subtypes->collect(c|c.ord)=Bag{1..subtypes->size} and
subtypes->forAll(sub1,sub2|sub1<>sub2 implies sub1.ord<>sub2.ord) and
if (flavour=strong) then
self.children->forAll(x|
(x.oclType.ord=self.oclType.ord-1) or
(self.oclType.ord=1 and x.oclType=Leaf))
else
self.children->forAll(x|
x.oclType.ord<=self.oclType.ord or
x.oclType=Leaf)
endif
Composite_Add.ocl
Postcondition
if (result=true) then (self.children->count(c)=1)
else self.children->count(c)=self.children@pre->count(c)
endif
Composite_Remove.ocl
Postcondition
self.children->select(p|p=c)->size=0