package Ġcom . phil ip g ur r . data . repository Ċ Ċ import Ġcom . phil ip g ur r . data . database . Shopping List Datasource Ċ import Ġcom . phil ip g ur r . domain . Product Ċ import Ġcom . phil ip g ur r . domain . Shopping List Ċ import Ġcom . phil ip g ur r . domain . repository . Shopping List Repository Ċ import Ġcom . phil ip g ur r . domain . util . completed Products Ċ import Ġcom . phil ip g ur r . domain . util . to Id Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠStandard Shopping List Repository Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġshopping List Datasource : ĠShop ping List Datasource Ċ ) Ġ: ĠShop ping List Repository Ġ{ ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun ĠgetList ( name : ĠString ): ĠShop ping List Ġ{ ĊĠĠĠĠĠĠĠ Ġrequire ("" Ġ!= Ġname ) Ġ{ Ġ" Name Ġmust Ġnot Ġbe Ġempty " Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġshopping List Datasource . get ( name . to Id ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun ĠgetAll Lists () Ġ= Ġshopping List Datasource . getAll () ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget Not Completed Lists () Ġ= ĊĠĠĠĠĠĠĠ ĠgetAll Lists (). filter Ġ{ Ġshopping List Ġ-> Ġis Incomplete ( shopping List ) Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Incomplete ( shopping List : ĠShop ping List ) Ġ= ĊĠĠĠĠĠĠĠ Ġshopping List . products . size Ġ== Ġ 0 Ġ|| Ġshopping List . completed Products (). size Ġ< Ġshopping List . products . size ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget Completed Lists () Ġ= ĊĠĠĠĠĠĠĠ ĠgetAll Lists (). filter Ġ{ Ġshopping List Ġ-> Ġis Complete ( shopping List ) Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġis Complete ( shopping List : ĠShop ping List ) Ġ= ĊĠĠĠĠĠĠĠ Ġshopping List . products . size Ġ!= Ġ 0 Ġ&& Ġshopping List . completed Products (). size Ġ== Ġshopping List . products . size ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġadd List ( value : ĠShop ping List ) Ġ{ ĊĠĠĠĠĠĠĠ Ġshopping List Datasource . insert ( value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġadd Lists ( values : ĠList < Shopping List >) Ġ{ ĊĠĠĠĠĠĠĠ Ġshopping List Datasource . insert All ( values ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġdelete List ( id : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġshopping List Datasource . delete ( id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget Products ( list : ĠShop ping List ) Ġ= ĊĠĠĠĠĠĠĠ Ġshopping List Datasource . getAll Products ( list . id ) ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġadd Product ( list : ĠShop ping List , Ġvalue : ĠProduct ) Ġ{ ĊĠĠĠĠĠĠĠ Ġshopping List Datasource . insert Product ( list . id , Ġvalue ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġdelete Product ( list : ĠShop ping List , Ġproduct : ĠProduct ) Ġ{ ĊĠĠĠĠĠĠĠ Ġshopping List Datasource . delete Product ( list . id , Ġproduct ) ĊĠĠĠ Ġ} Ċ }