State machine framework for Java