Implementation of UML state machien in Scala