Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created August 1, 2018 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/447285403b573fdcb7a876f7cffb5b99 to your computer and use it in GitHub Desktop.
Save jezinka/447285403b573fdcb7a876f7cffb5b99 to your computer and use it in GitHub Desktop.
static Cell transition(event, Cell cell) {
List states = state_machine_definition[cell.state]
def transition = states.find { it.event == event }
if (!transition) {
throw new Exception("invalid event $event for state ${cell.state}")
}
Cell tempCell = new Cell(transition.to, cell.lifeLong)
if (transition.afterAction) {
tempCell."${transition.afterAction}"()
}
return tempCell
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment