@Test void buildRecord() { final Schema customSchema = factory .newSchemaBuilder(baseSchema) .withEntry(factory.newEntryBuilder().withName("custom").withType(STRING).withNullable(true).build()) .build(); final List<Collection<String>> spy = asList(new LinkedList<>(), new LinkedList<>()); final Record noCustomRecord = service.create(customSchema, baseRecord, (entry, builder) -> { spy.get(0).add("visited=" + entry.getName()); if (entry.getName().equals("custom")) { builder.withString("custom", "yes"); return true; } return false; }, (builder, done) -> { spy.get(0).add("done=" + done); if (!done) { builder.withString("custom", "yes"); } }); final Record customRecord = service.create(customSchema, noCustomRecord, (entry, builder) -> { spy.get(1).add("visited=" + entry.getName()); if ("custom".equals(entry.getName())) { builder.withString("custom", "yes"); return true; } return false; }, (builder, done) -> spy.get(1).add("done=" + done)); Stream .of(noCustomRecord, customRecord) .forEach(record -> assertEquals( "name=Test,age=33,address={\"street\":\"here\",\"number\":1},custom=yes", toString(record))); assertEquals(asList("visited=name", "visited=age", "visited=address", "done=false"), spy.get(0)); assertEquals(asList("visited=name", "visited=age", "visited=address", "visited=custom", "done=true"), spy.get(1)); }
@Override public Record create(final Schema schema, final Record fallbackRecord, final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler, final BiConsumer<Record.Builder, Boolean> beforeFinish) { return fallbackRecord .getSchema() .getEntries() .stream() .collect(toRecord(schema, fallbackRecord, customHandler, beforeFinish)); }
RecordServiceImpl implements RecordService, Serializable { @Override public Record create(final Schema schema, final Record fallbackRecord, final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler, final BiConsumer<Record.Builder, Boolean> beforeFinish) { return fallbackRecord .getSchema() .getEntries() .stream() .collect(toRecord(schema, fallbackRecord, customHandler, beforeFinish)); } }
RecordServiceImpl implements RecordService, Serializable { @Override public Record create(final Schema schema, final Record fallbackRecord, final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler, final BiConsumer<Record.Builder, Boolean> beforeFinish) { return fallbackRecord .getSchema() .getEntries() .stream() .collect(toRecord(schema, fallbackRecord, customHandler, beforeFinish)); }  }
RecordServiceImpl implements RecordService, Serializable { @Override public Record create(final Schema schema, final Record fallbackRecord, final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler, final BiConsumer<Record.Builder, Boolean> beforeFinish) { return fallbackRecord .getSchema() .getEntries() .stream() .collect(toRecord(schema, fallbackRecord, customHandler, beforeFinish)); }  @Override Collector<Schema.Entry, Record.Builder, Record> toRecord(final Schema schema, final Record fallbackRecord,
            final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler,
            final BiConsumer<Record.Builder, Boolean> beforeFinish); @Override Record create(final Schema schema, final Record fallbackRecord,
            final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler,
            final BiConsumer<Record.Builder, Boolean> beforeFinish); @Override T visit(final RecordVisitor<T> visitor, final Record record); @Override T toObject(final Record data, final Class<T> expected); @Override Record toRecord(final T data); @Override boolean forwardEntry(final Record source, final Record.Builder builder, final String sourceColumn,
            final Schema.Entry entry); }
RecordServiceImpl implements RecordService, Serializable { @Override public Record create(final Schema schema, final Record fallbackRecord, final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler, final BiConsumer<Record.Builder, Boolean> beforeFinish) { return fallbackRecord .getSchema() .getEntries() .stream() .collect(toRecord(schema, fallbackRecord, customHandler, beforeFinish)); }  @Override Collector<Schema.Entry, Record.Builder, Record> toRecord(final Schema schema, final Record fallbackRecord,
            final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler,
            final BiConsumer<Record.Builder, Boolean> beforeFinish); @Override Record create(final Schema schema, final Record fallbackRecord,
            final BiFunction<Schema.Entry, Record.Builder, Boolean> customHandler,
            final BiConsumer<Record.Builder, Boolean> beforeFinish); @Override T visit(final RecordVisitor<T> visitor, final Record record); @Override T toObject(final Record data, final Class<T> expected); @Override Record toRecord(final T data); @Override boolean forwardEntry(final Record source, final Record.Builder builder, final String sourceColumn,
            final Schema.Entry entry);  }