private void init() {
Class<?> clazz = stateMachine.getClass();
while (clazz != Object.class) {
for (Method method : clazz.getDeclaredMethods()) {
// Check whether this method is a "command" method.
Command command = findAnnotation(method, Command.class);
if (command != null) {
addCommandMethod(method, command);
} else {
// Check whether this method is a "query" method.
Query query = findAnnotation(method, Query.class);