package Ġcom . github . example Ċ Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . stereotype . Component Ċ import Ġorg . springframework . util . Assert Ċ Ċ import Ġcom . github . example . data . Course Ċ import Ġcom . github . example . exception . AlreadyExists Exception Ċ import Ġcom . github . example . exception . NotFoundException Ċ import Ġcom . github . example . repository . Course Repository Ċ Ċ @ Component Ċ class ĠCourse Facade Impl ( val Ġcourse Repository : ĠCourse Repository ) Ġ: ĠCourse Facade Ġ{ ĊĊ ĉ override Ġfun Ġcreate Course ( course : ĠCourse ): ĠCourse Ġ{ Ċĉ ĉ Assert . notNull ( course , Ġ" The Ġgiven ĠCourse Ġmust Ġnot Ġbe Ġnull !") Ċĉ ĉ course . id ?. let Ġ{ Ċĉĉ ĉ if Ġ( course Repository . exists ( course . id )) Ġ{ Ċĉĉĉ ĉ throw ĠAlready Exists Exception (" Course Ġwith Ġgiven Ġid Ġalready Ġexists ") Ċĉĉ ĉ } ĉĉĉ Ċĉ ĉ } Ċĉ ĉ return Ġcourse Repository . save ( course ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġget Course ( course Id : ĠString ): ĠCourse Ġ{ Ċĉ ĉ Assert . notNull ( course Id , Ġ" The Ġgiven ĠCourse Id Ġmust Ġnot Ġbe Ġnull !") Ċĉ ĉ val Ġcourse Ġ= Ġcourse Repository . findOne ( course Id ) Ċĉ ĉ if Ġ( course Ġ== Ġnull ) Ġ{ Ċĉĉ ĉ throw ĠNotFound Exception (" Course Ġnot Ġfound ") Ċĉ ĉ } Ċĉ ĉ return Ġcourse Ċ ĉ } ĊĊ ĉ override Ġfun Ġupdate Course ( course : ĠCourse ): ĠCourse Ġ{ Ċĉ ĉ Assert . notNull ( course , Ġ" The Ġgiven ĠCourse Ġmust Ġnot Ġbe Ġnull !") Ċĉ ĉ if Ġ(! course Repository . exists ( course . id )) Ġ{ Ċĉĉ ĉ throw ĠNotFound Exception (" Course Ġnot Ġfound ") Ċĉ ĉ } Ċĉ ĉ return Ġcourse Repository . save ( course ); Ċ ĉ } Ċ Ċ } Ċ