DelimitedRecordMarshaller implements RecordMarshaller<P, String> { @Override public StringRecord processRecord(final Record<P> record) throws Exception { Iterable<Object> values = fieldExtractor.extractFields(record.getPayload()); StringBuilder stringBuilder = new StringBuilder(); Iterator<?> iterator = values.iterator(); while (iterator.hasNext()) { Object value = iterator.next(); stringBuilder.append(qualifier); stringBuilder.append(value); stringBuilder.append(qualifier); if (iterator.hasNext()) { stringBuilder.append(delimiter); } } return new StringRecord(record.getHeader(), stringBuilder.toString()); } DelimitedRecordMarshaller(final Class<P> type, final String... fields);  DelimitedRecordMarshaller(FieldExtractor<P> fieldExtractor); @Override StringRecord processRecord(final Record<P> record); void setDelimiter(final String delimiter); void setQualifier(final String qualifier); static final String DEFAULT_DELIMITER; static final String DEFAULT_QUALIFIER; }
@Test public void marshal() throws Exception { String expectedPayload = "\"foo\",\"bar\",\"false\""; StringRecord actual = marshaller.processRecord(record); assertThat(actual.getHeader()).isEqualTo(header); assertThat(actual.getPayload()).isEqualTo(expectedPayload); }