package Ġar cs . android . cr dt Ċ Ċ import Ġandroid . os . Parcel Ċ import Ġar cs . android . util . read Proto Ċ import Ġar cs . core . common . Refer enc able Ċ import Ġar cs . core . cr dt . Cr dt Entity Ċ import Ġar cs . core . data . FieldType Ċ import Ġar cs . core . data . Raw Entity Ċ import Ġar cs . core . data . util . Refer enc able List Ċ import Ġar cs . core . data . util . Refer enc able Primitive Ċ import Ġar cs . core . storage . Reference Ċ Ċ /** ĠConstructs Ġa Ġ[ Refer enc able ] Ġfrom Ġthe Ġgiven Ġ[ Refer enc able Proto ]. Ġ*/ Ċ fun ĠRefer enc able Proto . to Refer enc able (): ĠRefer enc able ? Ġ= Ġwhen Ġ( refer enc able Case ) Ġ{ ĊĠ ĠRefer enc able Proto . Refer enc able Case . REFER ENC ABLE _ NOT _ SET Ġ-> Ġnull ĊĠ ĠRefer enc able Proto . Refer enc able Case . RAW _ ENTITY Ġ-> Ġraw Entity . to Raw Entity () ĊĠ ĠRefer enc able Proto . Refer enc able Case . CR DT _ ENTITY _ REFERENCE Ġ-> ĊĠĠĠ Ġcr dt Entity Reference . to Cr dt Entity Reference () ĊĠ ĠRefer enc able Proto . Refer enc able Case . WRAP PED _ REFER ENC ABLE Ġ-> ĊĠĠĠ ĠCr dt Entity . Reference . wrap Refer enc able ( wrapped Refer enc able . to Refer enc able () !! ) ĊĠ ĠRefer enc able Proto . Refer enc able Case . REFERENCE Ġ-> Ġreference . to Reference () ĊĠ ĠRefer enc able Proto . Refer enc able Case . PR IMIT IVE Ġ-> Ġprimitive . to Refer enc able Primitive () ĊĠ ĠRefer enc able Proto . Refer enc able Case . PR IMIT IVE _ LIST Ġ-> Ġprimitive List . to Refer enc able List () ĊĠ ĠRefer enc able Proto . Refer enc able Case . REFERENCE _ LIST Ġ-> Ġreference List . to Refer enc able List () ĊĠ ĠRefer enc able Proto . Refer enc able Case . INLINE _ ENTITY _ LIST Ġ-> Ġinline Entity List . to Refer enc able List () ĊĠ Ġelse Ġ-> Ġthrow ĠUnsupportedOperationException ( ĊĠĠĠ Ġ" Unknown ĠRefer enc able Proto Ġtype : Ġ$ refer enc able Case ." ĊĠ Ġ) Ċ } Ċ Ċ /** ĠSerial izes Ġa Ġ[ Refer enc able ] Ġto Ġits Ġproto Ġform . Ġ*/ Ċ fun ĠRefer enc able . to Proto (): ĠRefer enc able Proto Ġ{ ĊĠ Ġval Ġproto Ġ= ĠRefer enc able Proto . newBuilder () ĊĠ Ġwhen Ġ( this ) Ġ{ ĊĠĠĠ Ġis ĠRaw Entity Ġ-> Ġproto . raw Entity Ġ= Ġto Proto () ĊĠĠĠ Ġis ĠCr dt Entity . Reference Impl Ġ-> Ġproto . cr dt Entity Reference Ġ= Ġto Proto () ĊĠĠĠ Ġis ĠCr dt Entity . Wrapped Refer enc able Ġ-> Ġproto . wrapped Refer enc able Ġ= Ġunwrap (). to Proto () ĊĠĠĠ Ġis ĠReference Ġ-> Ġproto . reference Ġ= Ġto Proto () ĊĠĠĠ Ġis ĠRefer enc able Primitive < *> Ġ-> Ġproto . primitive Ġ= Ġto Proto () ĊĠĠĠ Ġis ĠRefer enc able List < *> Ġ-> Ġ{ ĊĠĠĠĠĠ Ġval Ġitem Type Ġ= Ġthis . item Type ĊĠĠĠĠĠ Ġrequire ( item Type Ġis ĠFieldType . ListOf ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ" Refer enc able Lists Ġshould Ġhave Ġlist Ġfield Ġtypes Ġbut Ġthis Ġone Ġhas Ġ$ item Type " ĊĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠ Ġwhen Ġ( item Type . primitive Type ) Ġ{ ĊĠĠĠĠĠĠĠ Ġis ĠFieldType . Primitive Ġ-> Ġproto . primitive List Ġ= Ġto Primitive List Proto () ĊĠĠĠĠĠĠĠ Ġis ĠFieldType . Entity Ref Ġ-> Ġproto . reference List Ġ= Ġto Reference List Proto () ĊĠĠĠĠĠĠĠ Ġis ĠFieldType . Inline Entity Ġ-> Ġproto . inline Entity List Ġ= Ġto Inline Entity List Proto () ĊĠĠĠĠĠĠĠ Ġelse Ġ-> Ġthrow ĠUnsupportedOperationException (" Unsupported ĠRefer enc able : Ġ$ this .") ĊĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ Ġelse Ġ-> Ġthrow ĠUnsupportedOperationException (" Unsupported ĠRefer enc able : Ġ$ this .") ĊĠ Ġ} ĊĠ Ġreturn Ġproto . build () Ċ } Ċ Ċ /** ĠReads Ġa Ġ[ Refer enc able ] Ġout Ġof Ġa Ġ[ Parcel ]. Ġ*/ Ċ fun ĠParcel . read Refer enc able (): ĠRefer enc able ? Ġ= ĊĠ Ġread Proto ( Refer enc able Proto . getDefaultInstance ()) ?. to Refer enc able () Ċ