Skip to content

Implementation Role Feature 4

Max Leuthäuser edited this page Oct 16, 2015 · 6 revisions

Title

Objects may play the same role (type) several times

Description

Unlike feature 3 this does not correspond to multiple classification of an object. Instead it should be possible that each occurrence of an object in a role is associated with a different state. E.g. an employee has one salary and one office address per job.

Implementation

Simply instantiate a role multiple times and attach it.

val someCoreA = new CoreA()

val someRole1 = new RoleA()
val someRole2 = new RoleA()

someCoreA play someRole1
someCoreA play someRole2

(From: MinimalRoleSpec.scala)

Additional hints

To distinguish between role instances of the same role type SCROLL uses their object identity (equals- and hashCode-methods). So be careful when overriding/implementing them manually.

Clone this wiki locally