s3.addTransition(new MethodTransition("stop", s4, "stopped", handler));
s3.addTransition(new MethodTransition("pause", s5, "paused", handler));
s4.addTransition(new MethodTransition("eject", s1, "ejected", handler));
s5.addTransition(new MethodTransition("pause", s3, "playing", handler));
s2.addOnEntrySelfTransaction(new MethodSelfTransition("onEntryS2", handler));
s2.addOnExitSelfTransaction(new MethodSelfTransition("onExitS2", handler));
s3.addOnEntrySelfTransaction(new MethodSelfTransition("onEntryS3", handler));
s3.addOnExitSelfTransaction(new MethodSelfTransition("onExitS3", handler));
s4.addOnEntrySelfTransaction(new MethodSelfTransition("onEntryS4", handler));
s4.addOnExitSelfTransaction(new MethodSelfTransition("onExitS4", handler));
StateMachine sm = new StateMachine(new State[] { s1, s2, s3, s4, s5 }, "s1");
TapeDeck player = new StateMachineProxyBuilder().create(TapeDeck.class, sm);
player.insert("Kings of convenience - Riot on an empty street");
player.start();