protected boolean setConfiguredPropertyIfChanged ( final ConfiguredPropertyDescriptor configuredProperty , final Object value ) { if ( configuredProperty == null ) { throw new IllegalArgumentException ( "configuredProperty cannot be null" ) ; } final Object currentValue = configuredProperty . getValue ( _configurableBean ) ; if ( EqualsBuilder . equals ( currentValue , value ) ) { // no change return false ; } if ( value != null ) { boolean correctType = true ; if ( configuredProperty . isArray ( ) ) { if ( value . getClass ( ) . isArray ( ) ) { int length = Array . getLength ( value ) ; for ( int i = 0 ; i < length ; i ++ ) { Object valuePart = Array . get ( value , i ) ; if ( valuePart == null ) { logger . warn ( "Element no. {} in array (size {}) is null! Value passed to {}" , new Object [ ] { i , length , configuredProperty } ) ; } else { if ( ! ReflectionUtils . is ( valuePart . getClass ( ) , configuredProperty . getBaseType ( ) ) ) { correctType = false ; } } } } else { if ( ! ReflectionUtils . is ( value . getClass ( ) , configuredProperty . getBaseType ( ) ) ) { correctType = false ; } } } else { if ( ! ReflectionUtils . is ( value . getClass ( ) , configuredProperty . getBaseType ( ) ) ) { correctType = false ; } } if ( ! correctType ) { throw new IllegalArgumentException ( "Invalid value type: " + value . getClass ( ) . getName ( ) + ", expected: " + configuredProperty . getBaseType ( ) . getName ( ) ) ; } } configuredProperty . setValue ( _configurableBean , value ) ; return true ; }
Sets a configured property if it has changed .