OCL

Contents
      1. Typen
      2. Operatorenrangfolge
      3. Collections
        1. Literale
        2. Queries
        3. BExpr
--> These are only unorganized notes!
context (self :) Bruch inv invName:
	 self.nenner.faktoren->oclAsType(Set)->intersection(self.zaehler.faktoren.oclAsType)
context (self :) Bruch::mult(rhs: Bruch):

Typen

(7.4) Boolean ::= true false Real <- Integer String --- Collection <- Set, Sequence, Bag
(7.5.9) Eigenschaften aller Objekte: oclIsTypeOf(OclType) : Boolean oclIsKindOf(OclType) : Boolean -- transitives TypeOf oclInState(OclState) : Boolean oclIsNew() : Boolean -- Nach Postcondition entstanden oclAsType(OclType T) : T
Klasseneigenschaft: T.allInstances() : Set<T>

Operatorenrangfolge

Objektzugriff > Unäre > Punkt > bin. Strich > if > Arith. Vergleich > bin. boolesche Op. stark --> ( "@pre" ) ( "." "->" ) ( "not" "-" ) ( "*" "/" )
	("+" "-") (if-then-else-endif) ("<" ">" "<=" ">=")
	("=" "<>") ("and" "or" "xor") (implies) <-- schwach

Collections

Literale

Set/Bag { 1, 2 } Sequence { 1..3 }

Queries

collection->select(item: Type | expr(item) )
    -"-     reject     -"-
collection->
-> Subset(Coll.Typ)
collection.collect(item: Type | what_expr(item) ) animals.collect(beast: Animal | beast.name )
-> Bag

BExpr

animals->forAll(beast: Animal | beast.age >= 0) animals->forAll(a1, a2 : Animal | a1.name == a2.name implies a1 == a2)
->exists

EditContents