public static void setFieldValue ( Object obj , ReflectedInfo info , Object value ) throws Siren4JException { if ( obj == null ) { throw new IllegalArgumentException ( "obj cannot be null" ) ; } if ( info == null ) { throw new IllegalArgumentException ( "info cannot be null" ) ; } if ( info . getSetter ( ) != null ) { Method setter = info . getSetter ( ) ; setter . setAccessible ( true ) ; try { setter . invoke ( obj , new Object [ ] { value } ) ; } catch ( Exception e ) { throw new Siren4JException ( e ) ; } } else { // No setter set field directly try { info . getField ( ) . set ( obj , value ) ; } catch ( Exception e ) { throw new Siren4JException ( e ) ; } } }
Sets the fields value first by attempting to call the setter method if it exists and then falling back to setting the field directly .