package Ġcom . example . events . domain . use case Ċ Ċ import Ġcom . example . events . data . model . Event Ċ import Ġcom . example . events . data . model . Person Ċ import Ġcom . example . events . data . repository . Event Repository Impl Ċ import Ġcom . example . events . domain . exception . Person Already In Event Exception Ċ import Ġcom . example . events . domain . transform . Event Person Transform Ċ import Ġjava . lang . Exception Ċ Ċ class ĠJoin Event UseCase ( ĊĠĠĠ Ġval Ġrepository : ĠEvent Repository Impl , ĊĠĠĠ Ġval Ġtransform : ĠEvent Person Transform Ċ ) Ġ{ ĊĠĠĠ Ġsuspend Ġfun Ġjoin Event ( event : ĠEvent , Ġperson : ĠPerson ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ(! event . people . isEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġevent . people . forEach Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( it Ġ== Ġperson ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠPerson Already In Event Exception () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġrepository . join Event ( transform . transform Into Event Person ( event , Ġperson )) ĊĠĠĠ Ġ} Ċ }