Skip to content

Implementation Role Feature 5

Max Leuthäuser edited this page Nov 18, 2021 · 6 revisions

Title

Objects may acquire and abandon roles dynamically

Description

This allows for dynamic object classification.

Implementation

Simply use the play- and drop-method to acquire and abandon roles.

val someCore = new CoreA()
val someRole = new RoleA()

someCore play someRole
someCore drop someRole

(E.g., CompartmentRoleFeaturesTest.scala)

Additional hints

The internal state of the core- and the role-instance are not lost of course after dropping roles. They are available as long as you keep a reference to them somewhere (and the garbage collection does not kick in).

Clone this wiki locally