package Ġru . bor on in . simple weather . data . repository Ċ Ċ import Ġio . reactivex . Maybe Ċ import Ġru . bor on in . simple weather . data . datab se . Cache Source Ċ import Ġru . bor on in . simple weather . data . network . Network Source Ċ import Ġru . bor on in . simple weather . domain . repository . Weather Repository Ċ import Ġru . bor on in . simple weather . model . common . presentation . Forecast Model Ċ import Ġru . bor on in . simple weather . model . common . presentation . mapper . Forecast Model Mapper Ċ Ċ /** Ċ Ġ* ĠCreated Ġby ĠSer ge y ĠBor on in Ġon Ġ 0 6 . 0 3 . 2 0 2 0 . Ċ Ġ*/ Ċ class ĠWeather Repository Impl ( ĊĠ Ġprivate Ġval Ġnetwork Source : ĠNetwork Source , ĊĠ Ġprivate Ġval Ġcache Source : ĠCache Source , ĊĠ Ġprivate Ġval Ġmapper : ĠFore cast Model Mapper Ċ ) Ġ: ĠWeather Repository Ġ{ ĊĠ Ġoverride Ġfun ĠgetCurrent Weather ( lat : ĠFloat , Ġlon : ĠFloat ) Ġ= Ġnetwork Source . get Weather ( lat , Ġlon ) ĊĠ Ġoverride Ġfun Ġget Detailed Weather ( lat : ĠFloat , Ġlon : ĠFloat ) Ġ= Ġnetwork Source . get Detailed Weather ( ĊĠĠĠ Ġlat , ĊĠĠĠ Ġlon ĊĠ Ġ) ĊĊĠ Ġoverride Ġfun Ġsave Forecast ( forecast : ĠFore cast Model ) Ġ{ ĊĠĠĠ Ġval Ġentity Ġ= Ġmapper . map ( forecast ) ĊĠĠĠ Ġcache Source . save Forecast ( entity ) ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun Ġget Cached Forecast (): ĠMaybe < Forecast Model > Ġ{ ĊĠĠĠ Ġreturn ĠMaybe . create Ġ{ ĊĠĠĠĠĠ Ġval Ġforecast Ġ= Ġcache Source . get Forecast () ĊĠĠĠĠĠ Ġif Ġ( forecast Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠ Ġit . on Success ( mapper . map ( forecast )) ĊĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠ Ġit . onComplete () ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠ Ġ} Ċ } Ċ