The working man's state machine, written in Java