Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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