package Ġadapter .` in ` Ċ Ċ import Ġdomain . Language Ċ import Ġjava . util . Locale Ċ Ċ object ĠLocale Resolver Ġ{ Ċ ĉ fun Ġget Language From Header ( accept Language HeaderValue : ĠString ?): ĠLanguage ? Ġ= Ċĉ ĉ accept Language HeaderValue Ċĉĉ ĉ ?. split (',') Ċĉĉ ĉ ?. map (:: Accept Language Header Single Value ) Ċĉĉ ĉ ?. filter ( Accept Language Header Single Value :: is Supported ) Ċĉĉ ĉ ?. max OrNull () Ċĉĉ ĉ ?. supported Language Ċ } Ċ Ċ class ĠAccept Language Header Single Value ( header Value : ĠString ) Ġ: ĠComparable < Accept Language Header Single Value > Ġ{ Ċ ĉ private Ġval Ġlocale : ĠLocale Ċ ĉ private Ġval Ġq : ĠFloat Ċ ĉ val Ġsupported Language : ĠLanguage ? ĊĉĊ ĉ init Ġ{ Ċĉ ĉ val Ġheader Parts Ġ= Ġheader Value . split (' ; ') Ċĉ ĉ q Ġ= Ġheader Parts . elementAt OrNull ( 1 )?. substring After (' =') ?. toFloat () Ġ?: Ġ 1 . toFloat () Ċĉ ĉ val Ġlocale Parts Ġ= Ġheader Parts [ 0 ]. split ('- ') Ċĉ ĉ locale Ġ= ĠLocale ( locale Parts [ 0 ], Ġlocale Parts . elementAt OrNull ( 1 ) Ġ?: Ġ"", Ġlocale Parts . elementAt OrNull ( 2 ) Ġ?: Ġ"") Ċĉ ĉ supported Language Ġ= ĠLanguage . values (). first OrNull Ġ{ Ġit . supports ( locale ) Ġ} Ċ ĉ } ĊĉĊ ĉ fun Ġis Supported () Ġ= Ġsupported Language Ġ!= Ġnull ĊĉĊ ĉ override Ġfun Ġcompare To ( other : ĠAccept Language Header Single Value ): ĠInt Ġ= Ġq . compareTo ( other . q ) Ċ } Ċ