ApacheCommonCsvRecordMapper extends AbstractRecordMapper<P> implements RecordMapper<String, P> { @Override public Record<P> processRecord(final Record<String> record) throws Exception { String payload = record.getPayload(); CSVParser csvParser = csvFormat.parse(new StringReader(payload)); CSVRecord csvRecord = csvParser.iterator().next(); csvParser.close(); return new GenericRecord<>(record.getHeader(), objectMapper.mapObject(csvRecord.toMap())); } ApacheCommonCsvRecordMapper(Class<P> recordClass, String... columns); @Override Record<P> processRecord(final Record<String> record); void setTrim(boolean trim); void setDelimiter(char delimiter); void setQuote(char quote);  }
@Test public void testApacheCommonCsvMapping() throws Exception { StringRecord record = new StringRecord(header, "foo,bar,15,true"); Record<Foo> actual = mapper.processRecord(record); Foo foo = actual.getPayload(); assertThat(foo).isNotNull(); assertThat(foo.getFirstName()).isEqualTo("foo"); assertThat(foo.getLastName()).isEqualTo("bar"); assertThat(foo.getAge()).isEqualTo(15); assertThat(foo.isMarried()).isTrue(); }