0

For example say if I had a library and a precondition of issuing a book to a borrower was that it can only be issued if it is not reference only and is not already on loan to someone else, I could say:

context Copy::issue() : Boolean
    pre: (referenceCopy and onLoan) == false

But that would use the attribute onLoan for the book copy. Instead I want to say this with collection-methods to count related entities?

James
  • 161
  • 1
  • 8

1 Answers1

1

For example, you can use isEmpty()

context Copy::issue() : Boolean
    pre: not self.referenceCopy and self.borrowers->isEmpty()

or count()

context Copy::issue() : Boolean
    pre: not self.referenceCopy and self.borrowers->count() = 0

You can omit the context variable self if you want.

Fabian
  • 2,822
  • 1
  • 17
  • 22