private void writeObjectToField(String fieldname, Object value, Object object, Object alternative)
        throws Exception {
        Object target = object != null ? object : alternative;
        try {
            FieldUtils.writeField(target, fieldname, value, true);
        } catch (Exception e) {
            throw new IllegalArgumentException(String.format("Unable to write value '%s' to field '%s' of object %s",
                value.toString(), fieldname, target.getClass().getName()));
        }
    }
private void writeObjectToField ( String fieldname , Object value , Object object , Object alternative ) throws Exception { Object target = object != null ? object : alternative ; try { FieldUtils . writeField ( target , fieldname , value , true ) ; } catch ( Exception e ) { throw new IllegalArgumentException ( String . format ( "Unable to write value '%s' to field '%s' of object %s" , value . toString ( ) , fieldname , target . getClass ( ) . getName ( ) ) ) ; } }
Writes a value to the object from the field with the given name from either the object parameter or if this
parameter is null from the alternative parameter.