Vérifier les contraintes sur l'association (bidirectionnelle) Calendar <-> Agent
Description
We have a bidirectional relation between Calendar
and Agent
with a single reference of Calendar
in Agent
and a single reference of Person
in Calendar
.
Expected behavior
According to the given class diagram the cardinality between Calendar
and Agent
is Agent [1], and Calendar [1].
For any Agent a
:
-
a.calendar ≠ null
.
For any Calendar c
:
-
c.owner ≠ null
.
For any Agent a
and Calendar c
:
-
a.calendar == c
⇔c.owner == a
.
Proposal implementation
Use guard checking for cardinality of Calendar::owner
and Agent::calendar
, and ensure consistency by creating a basic...
variant of each setter.