package Ġcom . github . wp an as . migrate mongo Ċ Ċ import Ġcom . github . wp an as . migrate mongo . New Customer . Bank Account Ċ import Ġorg . bson . Document Ċ import Ġorg . springframework . core . convert . converter . Converter Ċ import Ġorg . springframework . data . convert . Reading Converter Ċ Ċ @ Reading Converter Ċ class ĠCustomer Converter Ġ: ĠConverter < Document , ĠNew Customer > Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġconvert ( source : ĠDocument ): ĠNew Customer Ġ= Ġwhen Ġ( source [" schema Version "]) Ġ{ ĊĠĠĠĠĠĠĠ ĠNew Customer . SCHEMA _ VERSION Ġ-> ĠNew Customer ( source . getString ( ID ), Ġconvert Multiple Bank Accounts ( source )) ĊĠĠĠĠĠĠĠ Ġelse Ġ-> ĠNew Customer ( source . getString ( ID ), Ġconvert Single Bank Account ( source )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġconvert Single Bank Account ( source : ĠDocument ) Ġ= ĊĠĠĠĠĠĠĠ Ġset Of ( Bank Account ( Customer . DEFAULT _ CUR RE NCY , Ġsource . getString ( Customer :: bank Account . name ))) ĊĊĠĠĠ Ġprivate Ġfun Ġconvert Multiple Bank Accounts ( source : ĠDocument ): ĠSet < Bank Account > Ġ= ĊĠĠĠĠĠĠĠ Ġ( source [ New Customer :: bank Accounts . name ] Ġas ĠList <* >) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġit Ġas ĠDocument ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠBank Account ( it . getString ( Bank Account :: currency . name ), Ġit . getString ( Bank Account :: number . name )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}. toSet () ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġconst Ġval ĠID Ġ= Ġ"_ id " ĊĠĠĠ Ġ} Ċ } Ċ