restoreByRecordedEvents

suspend fun StateMachine.restoreByRecordedEvents(recordedEvents: RecordedEvents, muteListeners: Boolean = true, disableStructureHashCodeCheck: Boolean = false, validator: RestorationResultValidator = StrictValidator): RestorationResult

Processes RecordedEvents with purpose of restoring a StateMachine to a state configuration as it was before (when the record was made). Starts the StateMachine if necessary and returns RestorationResult allowing to inspect how the restoration was processed. Specified RestorationResultValidator will be called to validate the result so do not have to remember to perform validation of the RestorationResult.

There is no way on library side to strictly decide if some exceptions during event processing are errors or not. For instance StateMachine may be configured with throwingIgnoredEventHandler so some exceptions might be expected and are not really errors. So this method collects all such warnings into RestorationResult object in a form of RestorationWarningException collections, delegating the responsibility for them to RestorationResultValidator object. StrictValidator is used by default and the library provides standard EmptyValidator to explicitly skip the validation step if necessary.

Parameters

muteListeners

listeners are not triggered by default, as we assume that client code reactions were already processed before.

disableStructureHashCodeCheck

allows to skip the machine structure check to force processing of RecordedEvents. Note that running the same event sequence on similar machines but having different structureHashCode value, may produce different results more likely.