public synchronized void stateMachine ( final DeviceState state ) throws DevFailed { if ( state != null ) { this . state = state . getDevState ( ) ; if ( setStateMethod != null ) { logger . debug ( "Changing state to {}" , state ) ; try { if ( setStateMethod . getParameterTypes ( ) [ 0 ] . equals ( DeviceState . class ) ) { setStateMethod . invoke ( businessObject , state ) ; } else { setStateMethod . invoke ( businessObject , this . state ) ; } } catch ( final IllegalArgumentException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final IllegalAccessException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } catch ( final InvocationTargetException e ) { if ( e . getCause ( ) instanceof DevFailed ) { throw ( DevFailed ) e . getCause ( ) ; } else { throw DevFailedUtils . newDevFailed ( e . getCause ( ) ) ; } } } } }
change state of the device