package Ġcom . ju ang m . random users . data . source . local Ċ Ċ import Ġandroidx . paging . DataSource Ċ import Ġcom . ju ang m . random users . data . mapper . map Local User To Domain Ċ import Ġcom . ju ang m . random users . data . source . local . room . Users Database Ċ import Ġcom . ju ang m . random users . data . source . local . room . entity . User Entity Ċ import Ġcom . ju ang m . random users . domain . models . User Ċ import Ġio . reactivex . Comp letable Ċ import Ġio . reactivex . Single Ċ Ċ class ĠUsers Local Source Impl ( private Ġval Ġusers Database : ĠUsers Database ): ĠUsers Local Source Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġget Users Count From Database (): ĠSingle < Int > Ġ= Ġusers Database . users Dao (). get Users Count () ĊĊĠĠĠ Ġoverride Ġfun Ġget Users From Database (): ĠDataSource . Factory < Int , ĠUser > Ġ= Ġusers Database . users Dao (). get Users () ĊĠĠĠĠĠĠĠ Ġ. map By Page Ġ{ Ġusers Ġ-> Ġusers . map ( map Local User To Domain ) Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Favorite Users From Database (): ĠSingle < List < User >> Ġ= Ġusers Database . users Dao (). get Favorite Users () ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġusers Ġ-> Ġusers . map ( map Local User To Domain ) Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsave Users In Database ( users : ĠList < User Entity >): ĠComp letable Ġ= Ġusers Database . users Dao (). insert Users ( users ) ĊĊĠĠĠ Ġoverride Ġfun Ġupdate User ( user : ĠUser Entity ): ĠComp letable Ġ= Ġusers Database . users Dao (). update ( user ) ĊĊĠĠĠ Ġoverride Ġfun Ġdelete Local Users (): ĠComp letable Ġ= Ġusers Database . users Dao (). delete All Users () Ċ }