src/main/java/edu/ucla/library/bucketeer/utils/AnnotationMappingStrategy.java
@Override
    @SuppressWarnings("PMD.PreserveStackTrace")
    public String[] transmuteBean(final T aBean) throws CsvDataTypeMismatchException, CsvRequiredFieldEmptyException {
        final List<String> values = new ArrayList<>();
        final String[] headers = generateHeader(aBean);
        final int columnCount = findMaxFieldIndex() + 1;

        // Loop through all our possible fields and supply empty strings where there are null values
        for (int index = 0; index < columnCount; index++) {
            final Field field = myValuesMap.get(headers[index]);

            // Mark field as accessible so we can read 'private' fields too
            field.setAccessible(true);

            try {
                final Object obj = field.get(aBean);
                final String value = StringUtils.trimTo(obj == null ? EMPTY : obj.toString(), EMPTY);

                // Add field value to our CSV values
                if (values.add(value)) {
                    LOGGER.debug(MessageCodes.BUCKETEER_108, headers[index], value);
                } else {
                    LOGGER.error(MessageCodes.BUCKETEER_109, headers[index]);
                }
            } catch (final IllegalAccessException details) {
                throw new CsvDataTypeMismatchException(details.getMessage());
            }
        }

        // Return the CSV row values
        return values.toArray(new String[] {});
    }
/**
     * Converts one bean into one CSV row.
     *
     * @param aBean A Java Bean
     */
Converts one bean into one CSV row.
@param aBean A Java Bean
Converts one bean into one CSV row . @param aBean A Java Bean
@Override
    @SuppressWarnings("PMD.PreserveStackTrace")
    public String[] transmuteBean(final T aBean) throws CsvDataTypeMismatchException, CsvRequiredFieldEmptyException {
        final List<String> values = new ArrayList<>();
        final String[] headers = generateHeader(aBean);
        final int columnCount = findMaxFieldIndex() + 1;
        for (int index = 0; index < columnCount; index++) {
            final Field field = myValuesMap.get(headers[index]);
            field.setAccessible(true);
            try {
                final Object obj = field.get(aBean);
                final String value = StringUtils.trimTo(obj == null ? EMPTY : obj.toString(), EMPTY);
                if (values.add(value)) {
                    LOGGER.debug(MessageCodes.BUCKETEER_108, headers[index], value);
                } else {
                    LOGGER.error(MessageCodes.BUCKETEER_109, headers[index]);
                }
            } catch (final IllegalAccessException details) {
                throw new CsvDataTypeMismatchException(details.getMessage());
            }
        }
        return values.toArray(new String[] {});
    }
@ Override @ SuppressWarnings ( "PMD.PreserveStackTrace" ) public String [ ] transmuteBean ( final T aBean ) throws CsvDataTypeMismatchException , CsvRequiredFieldEmptyException { final List < String > values = new ArrayList < > ( ) ; final String [ ] headers = generateHeader ( aBean ) ; final int columnCount = findMaxFieldIndex ( ) + 1 ; for ( int index = 0 ; index < columnCount ; index ++ ) { final Field field = myValuesMap . get ( headers [ index ] ) ; field . setAccessible ( true ) ; try { final Object obj = field . get ( aBean ) ; final String value = StringUtils . trimTo ( obj == null ? EMPTY : obj . toString ( ) , EMPTY ) ; if ( values . add ( value ) ) { LOGGER . debug ( MessageCodes . BUCKETEER_108 , headers [ index ] , value ) ; } else { LOGGER . error ( MessageCodes . BUCKETEER_109 , headers [ index ] ) ; } } catch ( final IllegalAccessException details ) { throw new CsvDataTypeMismatchException ( details . getMessage ( ) ) ; } } return values . toArray ( new String [ ] { } ) ; }
Converts one bean into one CSV row.
Converts one bean into one CSV row .
// Loop through all our possible fields and supply empty strings where there are null values // Mark field as accessible so we can read 'private' fields too // Add field value to our CSV values // Return the CSV row values