Professional Documents
Culture Documents
OCL Quick Reference PDF
OCL Quick Reference PDF
OCL Constructs
result
context In a postcondition, denotes the result of an operation.
Specifies the context for OCL expressions.
context Account::getBalance(): Integer
context Account post: result = balance
inv @pre
States a condition that must always be met by all instances of a In a postcondition, denotes the value of a property at the start of
context type. an operation.
context Account context Account::deposit(amt: Integer): void
inv: balance >= 0 post: balance = balance@pre + amt
pre Navigation
States a condition that must be true at the moment when an Navigation through attributes, association ends, association
operation starts its execution. classes, and qualified associations.
context Account::deposit(amt: Integer): void
context Account
pre: amt > 0
inv: self.balance >= 0 -- dot notation
-- collection operator (->)
post
inv: owners->size() > 0
States a condition that must be true at the moment when an -- association class, TransInfo
operation ends its execution. inv: transactions.TransInfo->forall(amount > 0)
context Account::deposit(amt: Integer): void -- qualified association, owners
post: balance = balance@pre + amt inv: not owners[primary].isOclUndefined()