protected void extractBeanValues ( final Object source , final String [ ] nameMapping ) throws SuperCsvReflectionException { Objects . requireNonNull ( nameMapping , "the nameMapping array can't be null as it's used to map from fields to columns" ) ; beanValues . clear ( ) ; for ( int i = 0 ; i < nameMapping . length ; i ++ ) { final String fieldName = nameMapping [ i ] ; if ( fieldName == null ) { beanValues . add ( null ) ; // assume they always want a blank column } else { Method getMethod = cache . getGetMethod ( source , fieldName ) ; try { beanValues . add ( getMethod . invoke ( source ) ) ; } catch ( final Exception e ) { throw new SuperCsvReflectionException ( String . format ( "error extracting bean value for field %s" , fieldName ) , e ) ; } } } }
Extracts the bean values using the supplied name mapping array .