package Ġcom . ec wid . apic lient . v 3 . json transformer . gson . type adapters Ċ Ċ import Ġcom . ec wid . apic lient . v 3 . exception . Json Deserialization Exception Ċ import Ġcom . ec wid . apic lient . v 3 . json transformer . Pol ymorphic Type Ċ import Ġcom . google . gson . Json Deserialization Context Ċ import Ġcom . google . gson . Json Deserializer Ċ import Ġcom . google . gson . Json Element Ċ import Ġjava . lang . reflect . Type Ċ Ċ class ĠGson Pol ymorphic Deserializer ( Ċĉ ĉ private Ġval Ġpol ymorphic Type : ĠPol ymorphic Type < *> Ċ ) Ġ: ĠJson Deserializer < Any ?> Ġ{ Ċ ĉ override Ġfun Ġdeserialize ( json : ĠJson Element , ĠtypeOf T : ĠType , Ġcontext : ĠJson Deserialization Context ): ĠAny ? Ġ{ Ċĉ ĉ val Ġtype Ġ= Ġjson . as JsonObject [ pol ymorphic Type . json FieldName ]?. asString ?. toLowerCase () Ċĉĉĉ ĉ ?: Ġthrow ĠJson Deserialization Exception (" Deserialization Ġpol ymorphic Ġtype Ġ${ type Of T . typeName } Ġfailed . ĠType Ġfield Ġ${ pol ymorphic Type . json FieldName } Ġmust Ġbe Ġnot Ġnull ", Ġnull ) ĊĊĉ ĉ val Ġchild Class Ġ= Ġpol ymorphic Type . child Classes [ type ] Ċĉĉĉ ĉ ?: Ġthrow ĠJson Deserialization Exception (" Deserialization Ġpol ymorphic Ġtype Ġ${ type Of T . typeName } Ġfailed . ĠType Ġfield Ġ${ pol ymorphic Type . json FieldName } Ġhas Ġunknown Ġvalue Ġ$ type ", Ġnull ) ĊĊĉ ĉ return Ġcontext . deserialize ( json , Ġchild Class ) Ċ ĉ } Ċ } Ċ