package Ġcom . be esh am . weather app . domain . dataSource Ċ Ċ import Ġcom . be esh am . weather app . data . db . Forecast Db Ċ import Ġcom . be esh am . weather app . data . server . Forecast Server Ċ import Ġcom . be esh am . weather app . domain . model . Forecast Ċ import Ġcom . be esh am . weather app . domain . model . Forecast List Ċ import Ġcom . be esh am . weather app . extensions . first Result Ċ Ċ class ĠFore cast Provider ( val Ġsources : ĠList < Forecast DataSource > Ġ= ĠFore cast Provider . SOURCES ) Ġ{ ĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠDAY _ IN _ M ILL IS Ġ= ĠĠ 1 0 0 0 Ġ* Ġ 6 0 Ġ* Ġ 6 0 Ġ* Ġ 2 4 ĊĠĠĠĠĠĠĠ Ġval ĠSO URCES Ġby Ġlazy Ġ{ ĠlistOf ( Forecast Db (), ĠFore cast Server ()) Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġrequest By Zip Code ( zip Code : ĠLong , Ġdays : ĠInt ): ĠFore cast List ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ= Ġrequest To Sources Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġres Ġ= Ġit . request Forecast By Zip Code ( zip Code , Ġtoday TimeSpan ()) ĊĠĠĠĠĠĠĠ Ġif Ġ( res Ġ!= Ġnull Ġ&& Ġres . size Ġ>= Ġdays ) Ġres Ġelse Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġrequest Forecast ( id : ĠLong ): ĠFore cast Ġ= Ġrequest To Sources Ġ{ ĊĠĠĠĠĠĠĠ Ġit . request Day Forecast ( id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġrequest Source ( source : ĠFore cast DataSource , Ġdays : ĠInt , Ġzip Code : ĠLong ): ĠFore cast List ? Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġres Ġ= Ġsource . request Forecast By Zip Code ( zip Code , Ġtoday TimeSpan ()) ĊĠĠĠĠĠĠĠ Ġreturn Ġif Ġ( res Ġ!= Ġnull Ġ&& Ġres . size Ġ>= Ġdays ) Ġres Ġelse Ġnull ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġtoday TimeSpan () Ġ= ĠSystem . currentTimeMillis () Ġ/ ĠDAY _ IN _ M ILL IS Ġ* ĠDAY _ IN _ M ILL IS ĊĊĠĠĠ Ġprivate Ġfun Ġ< T : ĠAny > Ġrequest To Sources ( f : Ġ( Forecast DataSource ) Ġ-> ĠT ?) Ġ: T Ġ= Ġsources . first Result Ġ{ Ġf ( it )} Ċ }