package Ġio . hol unda . addons . camunda . data . variable Ċ Ċ import Ġio . hol unda . addons . camunda . data . variable . adapter . Variable Read Adapter Ċ import Ġio . hol unda . addons . camunda . data . variable . adapter . Variable ReadWrite Adapter Ċ import Ġorg . camunda . bpm . engine . Case Service Ċ import Ġorg . camunda . bpm . engine . Runtime Service Ċ import Ġorg . camunda . bpm . engine . delegate . Variable Scope Ċ import Ġjava . util .* ĊĊ Ċ fun ĠRuntime Service . read Adapter ( process InstanceId : ĠString ): ĠVariable Read Adapter Ġ= Ġobject Ġ: ĠVariable Read Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġread ( variable ) Ġ{ Ġthis @ read Adapter . get Variable ( process InstanceId , Ġvariable . key ) Ġ} Ċ } Ċ fun ĠRuntime Service . read Write Adapter ( process InstanceId : ĠString ): ĠVariable ReadWrite Adapter Ġ= Ġobject Ġ: ĠVariable ReadWrite Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġwrite ( variable : ĠVariable < T >, Ġvalue : ĠT ): ĠT Ġ= Ġwrite ( variable , Ġvalue ) Ġ{ Ġv Ġ-> Ġthis @ read Write Adapter . set Variable ( process InstanceId , Ġvariable . key , Ġv ) Ġ}. let Ġ{ Ġvalue Ġ} ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġthis @ read Write Adapter . read Adapter ( process InstanceId ). read ( variable ) Ċ } ĊĊ Ċ fun ĠMap < String , ĠAny >. read Adapter () Ġ= Ġobject Ġ: ĠVariable Read Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġread ( variable ) Ġ{ Ġthis @ read Adapter [ variable . key ] Ġ} Ċ } Ċ fun ĠMutable Map < String , ĠAny >. read Write Adapter () Ġ= Ġobject Ġ: ĠVariable ReadWrite Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġwrite ( variable : ĠVariable < T >, Ġvalue : ĠT ): ĠT Ġ= Ġwrite ( variable , Ġvalue ) Ġ{ Ġv Ġ-> Ġthis @ read Write Adapter [ variable . key ] Ġ= Ġv Ġ}. let Ġ{ Ġvalue Ġ} ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġthis @ read Write Adapter . read Adapter (). read ( variable ) Ċ } Ċ Ċ fun ĠVariable Scope . read Adapter () Ġ= Ġobject Ġ: ĠVariable Read Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġread ( variable ) Ġ{ Ġthis @ read Adapter . get Variable ( variable . key ) Ġ} Ċ } Ċ fun ĠVariable Scope . read Write Adapter () Ġ= Ġobject Ġ: ĠVariable ReadWrite Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġwrite ( variable : ĠVariable < T >, Ġvalue : ĠT ): ĠT Ġ= Ġwrite ( variable , Ġvalue ) Ġ{ Ġv Ġ-> Ġthis @ read Write Adapter . set Variable ( variable . key , Ġv ) Ġ}. let Ġ{ Ġvalue Ġ} ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġthis @ read Write Adapter . read Adapter (). read ( variable ) Ċ } ĊĊ Ċ fun ĠCase Service . read Adapter ( case InstanceId : ĠString ): ĠVariable Read Adapter Ġ= Ġobject Ġ: ĠVariable Read Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġread ( variable ) Ġ{ Ġthis @ read Adapter . get Variable ( case InstanceId , Ġvariable . key ) Ġ} Ċ } Ċ fun ĠCase Service . read Write Adapter ( case InstanceId : ĠString ): ĠVariable Read Adapter Ġ= Ġobject Ġ: ĠVariable ReadWrite Adapter Ġ{ ĊĠ Ġoverride Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >): ĠOptional < T > Ġ= Ġthis @ read Write Adapter . read Adapter ( case InstanceId ). read ( variable ) ĊĠ Ġoverride Ġfun Ġ< T > Ġwrite ( variable : ĠVariable < T >, Ġvalue : ĠT ): ĠT Ġ= Ġwrite ( variable , Ġvalue ) Ġ{ Ġv Ġ-> Ġthis @ read Write Adapter . set Variable ( case InstanceId , Ġvariable . key , Ġv ) Ġ}. let Ġ{ Ġvalue Ġ} Ċ } ĊĊ Ċ private Ġfun Ġ< T > Ġread ( variable : ĠVariable < T >, Ġget Variable : Ġ() Ġ-> ĠAny ?) Ġ= ĠOptional . of Nullable ( get Variable ()). map Ġ{ Ġvariable . convert For Read ( it ) Ġ} Ċ private Ġfun Ġ< T > Ġwrite ( variable : ĠVariable < T >, Ġvalue : ĠT , Ġset Variable : Ġ( Any ) Ġ-> ĠUnit ) Ġ= Ġset Variable ( variable . convert For Write ( value )) Ċ