package Ġpl . be one . prom ena . core . internal . communication . external . manager Ċ Ċ import Ġmu . Kotlin Logging Ċ import Ġpl . be one . prom ena . core . application model . exception . communication . external . manager . External Communication NotFoundException Ċ import Ġpl . be one . prom ena . core . contract . communication . external . manager . External Communication Ċ import Ġpl . be one . prom ena . core . contract . communication . external . manager . External Communication Manager Ċ Ċ /** Ċ Ġ* ĠMan ages Ġ[ external Com munications ] Ġin Ġmemory . Ċ Ġ* ĠIn Ġcase Ġof Ġthe Ġabsence Ġof Ġan Ġinstance Ġof Ġ* external Ġcommunication *, Ċ Ġ* Ġthis Ġimplementation Ġuses Ġ* external Ġcommunication * Ġassociated Ġwith Ġ[ back Pressure Id ] Ġif Ġ[ back Pressure Communication Enabled ] Ġis Ġ` true `. Ċ Ġ*/ Ċ class ĠDefault External Communication Manager ( ĊĠĠĠ Ġprivate Ġval Ġexternal Com munications : ĠList < External Communication >, ĊĠĠĠ Ġprivate Ġval Ġback Pressure Communication Enabled : ĠBoolean , ĊĠĠĠ Ġprivate Ġval Ġback Pressure Id : ĠString Ċ ) Ġ: ĠExternal Communication Manager Ġ{ ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġlogger Ġ= ĠKotlin Logging . logger Ġ{} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġval Ġcommunication Map : ĠMap < String , ĠExternal Communication > ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġback Pressure Communication : ĠExternal Communication ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġcommunication Map Ġ= Ġcreate Communication Map ( external Com munications ) ĊĠĠĠĠĠĠĠ Ġif Ġ( back Pressure Communication Enabled ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġback Pressure Communication Ġ= Ġget Back Pressure Communication ( external Com munications , Ġback Pressure Id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Back Pressure Communication ( external Com munications : ĠList < External Communication >, Ġback Pressure Id : ĠString ): ĠExternal Communication Ġ= ĊĠĠĠĠĠĠĠ Ġexternal Com munications . first OrNull Ġ{ Ġ( id ) Ġ-> Ġid Ġ== Ġback Pressure Id Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġerror (" Couldn 't Ġdetermine Ġback Ġpressure Ġcommunication . Ġ" Ġ+ Ġcreate NotFoundException Message ( back Pressure Id , Ġexternal Com munications )) ĊĊĠĠĠ Ġoverride Ġfun Ġget Communication ( id : ĠString ): ĠExternal Communication Ġ= ĊĠĠĠĠĠĠĠ Ġcommunication Map [ id ] Ġ?: Ġdetermine Communication ( id ) ĊĊĠĠĠ Ġprivate Ġfun Ġdetermine Communication ( id : ĠString ): ĠExternal Communication Ġ= ĊĠĠĠĠĠĠĠ Ġif Ġ( back Pressure Communication Enabled ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlogger . warn Ġ{ Ġ" There Ġis Ġno Ġ<$ id > Ġexternal Ġcommunication . ĠUsing Ġ<$ back Pressure Id > Ġas Ġback Ġpressure " Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġback Pressure Communication ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠExternal Communication NotFoundException ( create NotFoundException Message ( id , Ġexternal Com munications )) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġcreate Communication Map ( external Com munications : ĠList < External Communication >): ĠMap < String , ĠExternal Communication > Ġ= ĊĠĠĠĠĠĠĠ Ġexternal Com munications . map Ġ{ Ġit . id Ġto Ġit Ġ}. toMap () ĊĊĠĠĠ Ġprivate Ġfun Ġcreate NotFoundException Message ( id : ĠString , Ġexternal Com munications : ĠList < External Communication >): ĠString Ġ= ĊĠĠĠĠĠĠĠ Ġ" There Ġis Ġno Ġ<$ id > Ġexternal Ġcommunication : Ġ${ external Com munications . map Ġ{ Ġit . id Ġ}}" Ċ }