### Question:
RecordDefinition { public static <T> Builder<T> builder(Class<T> dataType) { return new Builder<>(dataType); } RecordDefinition(
            Class<? extends T> dataType, List<FieldInfo<T, ?>> fields,
            HeaderType headerType,
            boolean trimInput, boolean skipEmptyInput,
            ErrorAction onMalformedInput, ErrorAction onUnmappableOutput,
            ErrorAction onLessInput, ErrorAction onMoreInput); static Builder<T> builder(Class<T> dataType); int getNumberOfFields(); TextInput<T> newInput(FieldReader reader, String path); TextInput<T> newInput(FieldReader reader, String path, Collection<? extends InputOption> options); TextOutput<T> newOutput(FieldWriter writer, String path); TextOutput<T> newOutput(FieldWriter writer, String path, Collection<? extends OutputOption> options);  }### Answer:
@Test public void input() throws Exception { RecordDefinition<String[]> def = RecordDefinition.builder(String[].class) .withField(self(), field(0).build()) .build(); String[][] results = collect(def, new String[][] { { "Hello, world!", }, }); assertThat(results, is(new String[][] { { "Hello, world!", }, })); }
@Test public void input_header() throws Exception { RecordDefinition<String[]> def = RecordDefinition.builder(String[].class) .withHeaderType(HeaderType.FORCE) .withField(self(), field(0).build()) .withField(self(), field(1).build()) .build(); String[][] results = collect(def, new String[][] { { "A", "B", }, { "C", "D", }, }); assertThat(results, is(new String[][] { { "C", "D", }, })); }
@Test public void input_header_not_head() throws Exception { RecordDefinition<String[]> def = RecordDefinition.builder(String[].class) .withHeaderType(HeaderType.FORCE) .withField(self(), field(0).build()) .withField(self(), field(1).build()) .build(); String[][] results = collect(def, Collections.emptySet(), new String[][] { { "A", "B", }, { "C", "D", }, }); assertThat(results, is(new String[][] { { "A", "B", }, { "C", "D", }, })); }
@Test public void output() throws Exception { RecordDefinition<String[]> def = RecordDefinition.builder(String[].class) .withField(self(), field(0).build()) .build(); String[][] results = emit(def, new String[][] { { "Hello, world!", }, }); assertThat(results, is(new String[][] { { "Hello, world!", }, })); }