-
-
Notifications
You must be signed in to change notification settings - Fork 12
Implementation Role Feature 11
Features of an object can be role-specific
Attributes and behavior of an object may be overloaded on a by-role basis, i.e., different roles may declare the same features, but realize them differently. If an object plays several of these roles simultaneously, it responds according to the role in which it is being addressed.
(Different) roles (may) have (different) properties and behavior (see feature 1) and attaching them to players will create an (compound-) object aggregating all those role-specific features.
In case you are accessing behavior (methods/functions) or properties (class attributes) with the exact same signature (name, argument types and return type) but still want to distinguish the appropriate target (-role) context-wise, you have to define an implicit dispatch description (DispatchQuery).
E.g.:
implicit val dd =
From(_.isInstanceOf[Account]).
To(_.isInstanceOf[CheckingsAccount]).
Through(anything).
Bypassing(_.isInstanceOf[CheckingsAccount])
Please have a look at the ScalaDoc at DispatchQuery.scala for an explanation of the functions From
, To
, Through
and Bypassing
.