package Ġcom . br un ot iba . repository Ċ Ċ import Ġcom . br un ot iba . domain . repository . Weather Repository Ċ import Ġcom . br un ot iba . repository . datasource . Forecast Cache Ċ import Ġcom . br un ot iba . repository . datasource . Weather DataSource Ċ import Ġcom . br un ot iba . repository . mapper . Forecast Mapper Ċ import Ġtim ber . log . Tim ber Ċ import Ġjavax . inject . Inject Ċ import Ġcom . br un ot iba . domain . model . Forecast Ġas ĠDomain Forecast Ċ import Ġcom . br un ot iba . repository . model . Forecast Ġas ĠRepo Forecast Ċ Ċ /** Ċ Ġ* ĠImplementation Ġof Ġ[ Weather Repository ] Ġthat Ġcaches Ġthe Ġweather Ġdata Ġto Ġavoid Ġunnecessary Ġrequests Ċ Ġ* Ġto Ġthe Ġweather Ġdata Ġsource . Ċ Ġ* Ċ Ġ* Ġ@ param Ġweather DataSource Ġthe Ġ[ Weather DataSource ] Ċ Ġ* Ġ@ param Ġforecast Cache Ġthe Ġ[ Forecast Cache ] Ċ Ġ* Ġ@ param Ġforecast Mapper Ġthe Ġmapper Ġto Ġconvert Ġ[ Repo Forecast ] Ġand Ġ[ Domain Forecast ] Ċ Ġ*/ Ċ class ĠWeather Repository Impl Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġweather DataSource : ĠWeather DataSource , ĊĠĠĠ Ġprivate Ġval Ġforecast Cache : ĠFore cast Cache , ĊĠĠĠ Ġprivate Ġval Ġforecast Mapper : ĠFore cast Mapper Ċ ) Ġ: ĠWeather Repository Ġ{ ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun ĠgetCurrent Forecast By City Name ( name : ĠString ): ĠDomain Forecast Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . d (" getCurrent Forecast By City Name Ġ- Ġname Ġ= Ġ$ name ") ĊĊĠĠĠĠĠĠĠ Ġval Ġforecast : ĠRepo Forecast Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġforecast Cache . get Forecast ByName ( name ) Ġ?: Ġretrieve Remote Forecast ( name ) ĊĠĠĠĠĠĠĠ Ġreturn Ġforecast Mapper . to Domain ( forecast ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġsuspend Ġfun Ġretrieve Remote Forecast ( name : ĠString ): ĠRepo Forecast Ġ{ ĊĠĠĠĠĠĠĠ ĠTim ber . d (" retrieve Remote Forecast Ġ- Ġname Ġ= Ġ$ name ") ĊĊĠĠĠĠĠĠĠ Ġval Ġforecast Ġ= Ġweather DataSource . getCurrent Forecast By City Name ( name ) ĊĠĠĠĠĠĠĠ Ġforecast Cache . insert Forecast ( forecast ) ĊĠĠĠĠĠĠĠ Ġreturn Ġforecast ĊĠĠĠ Ġ} Ċ } Ċ