Commit c8acc2ff authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Refactor and remove duplication

parent 39e8f663
......@@ -8,7 +8,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Function;
public abstract class OutputFile<K extends Comparable<K>> {
private String[] keyHeaders;
......@@ -53,26 +55,25 @@ public abstract class OutputFile<K extends Comparable<K>> {
private void printHeader(PrintWriter out) {
final List<String> fieldHeaders = new LinkedList<>(Arrays.asList(keyHeaders));
final List<String> processorFieldHeaders =
.flatMap(p ->
final List<String> fieldHeaders = composeLine(keyHeaders, p ->;
writeLine(out, fieldHeaders);
private void printRow(final PrintWriter out, final K key) {
final List<String> fields = new LinkedList<>(Arrays.asList(toStrings(key)));
final List<String> fields = composeLine(toStrings(key), p ->;
writeLine(out, fields);
private List<String> composeLine(String[] keyFieldArray, Function<Processor, Stream<String>> valueFields) {
final List<String> fields = new LinkedList<>(Arrays.asList(keyFieldArray));
final List<String> processorFields =
.flatMap(p ->
writeLine(out, fields);
return fields;
private void writeLine(PrintWriter out, final List<String> fields) {
out.println(String.join(SEPARATOR, fields));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment