A basic state machine implementation written in Java