public void build ( final Class < ? > clazz , final Field field , final DeviceImpl device , final Object businessObject ) throws DevFailed { xlogger . entry ( ) ; BuilderUtils . checkStatic ( field ) ; Method getter ; final String stateName = field . getName ( ) ; final String getterName = BuilderUtils . GET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { getter = clazz . getMethod ( getterName ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } if ( getter . getParameterTypes ( ) . length != 0 ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must not have a parameter" ) ; } logger . debug ( "Has an status : {}" , field . getName ( ) ) ; if ( getter . getReturnType ( ) != String . class ) { throw DevFailedUtils . newDevFailed ( DevFailedUtils . TANGO_BUILD_FAILED , getter + " must have a return type of " + String . class ) ; } Method setter ; final String setterName = BuilderUtils . SET + stateName . substring ( 0 , 1 ) . toUpperCase ( Locale . ENGLISH ) + stateName . substring ( 1 ) ; try { setter = clazz . getMethod ( setterName , String . class ) ; } catch ( final NoSuchMethodException e ) { throw DevFailedUtils . newDevFailed ( e ) ; } device . setStatusImpl ( new StatusImpl ( businessObject , getter , setter ) ) ; final Status annot = field . getAnnotation ( Status . class ) ; if ( annot . isPolled ( ) ) { device . addAttributePolling ( DeviceImpl . STATUS_NAME , annot . pollingPeriod ( ) ) ; } xlogger . exit ( ) ; }
Create a status