package Ġorg . s ug gs . fsm . stubs Ċ Ċ import Ġorg . slf 4 j . LoggerFactory Ċ import Ġorg . s ug gs . fsm . behavior . Event Ċ import Ġorg . s ug gs . fsm . execution . Business Object Reference Ċ import Ġorg . s ug gs . fsm . execution . F sm StateManager Ċ import Ġjava . time . LocalDateTime Ċ Ċ open Ġclass ĠStub F sm StateManager Ġ: ĠF sm StateManager Ġ{ ĊĊĠĠĠ Ġprivate Ġvar Ġstate : ĠString Ġ= Ġ"" ĊĠĠĠ Ġval Ġdeferred Events Ġ= ĠArrayList < Event >() ĊĠĠĠ Ġprivate Ġval Ġaud its Ġ= ĠArrayList < Audit >() ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġlog Ġ= ĠLoggerFactory . getLogger ( this :: class . java ) !! ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġstore Deferred Events ( var arg Ġevents : ĠEvent ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdeferred Events . addAll ( events ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Deferred Events (): ĠSet < Event > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġdeferred Events . toSet () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġremove Deferred Event ( eventName : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdeferred Events . remove If { Ġit . name Ġ== ĠeventName } ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġstore Active State ( state : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . state Ġ= Ġstate ĊĠĠĠĠĠĠĠ Ġaud its . add ( Audit ( state )) ĊĠĠĠĠĠĠĠ Ġlog . info (" Recording Ġstate Ġchange Ġto Ġ[$ state ]") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġget Active State ( business Object Reference : ĠBusiness Object Reference ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġstate ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġprint Aud its () Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuffer Ġ= ĠStringBuffer (" Transitions Ġaudit :\ n ") ĊĠĠĠĠĠĠĠ Ġaud its . map Ġ{ Ġbuffer . append (" Ġ- Ġ${ it . time Stamp } Ġ- Ġ${ it . event }\ n ") Ġ} ĊĠĠĠĠĠĠĠ Ġlog . info ( buffer . toString ()) ĊĠĠĠ Ġ} Ċ } Ċ Ċ data Ġclass ĠAudit ( val Ġevent : ĠString ){ ĊĠĠĠ Ġval Ġtime Stamp : ĠLocalDateTime Ġ= ĠLocalDateTime . now () Ċ }