Library Model (Structural and Object) example#

This image below shows the structural model and object model of Library

Library models (Structural and Object)

Some of the OCL Constraints defined on these models are shown below:

context Book inv inv2: self.pages>0

context Library inv inv3: if self.name <> 'NI' then self.has->exists"
       "( i_book : Book | i_book.pages <= 110 ) else self.has->forAll(b:Book|b.pages>0)"
       " endif

Some example constraints are defined in the Library example

More constrained can be defined using BUML Structural and rules classes as shown below:

constraintLibraryElse: Constraint = Constraint(name ="LibaryElse", context=library,
        expression="context Library inv inv3: if self.name = 'NI' then self.has->exists"
       "( i_book : Book | i_book.pages <= 110 ) else self.has->forAll(b:Book|b.pages>0)"
       " endif", language="OCL")