Finite State Machine for Java