public void changeState ( Class < ? extends State > next ) { Check . notNull ( next ) ; final State from = current ; if ( current != null ) { last = current . getClass ( ) ; current . exit ( ) ; } if ( ! states . containsKey ( next ) ) { final State state = create ( next ) ; states . put ( next , state ) ; } current = states . get ( next ) ; current . enter ( ) ; listeners . forEach ( l -> l . notifyStateTransition ( from != null ? from . getClass ( ) : null , next ) ) ; }
Change the current state .