The current CsvSchema.Builder doesn't support the fluent addition of multiple fields in a single operation. This makes it necessary to break out of the fluent interface temporarily to loop through field names before completing the build.
This could be supported through either 1 or 2 new operations added to CsvSchema.Builder:
public Builder addColumns(Iterable<Column> cs) {
for (Column c : cs) {
_columns.add(c);
}
return this;
}
public Builder addColumns(Iterable<String> names, ColumnType type) {
Builder result = this;
for (String name : names) {
result = addColumn(name, type);
}
return result;
}
Note that CsvSchema itself would match Iterable<Column>, which may or may not be what is most intuitive as it wouldn't copy across all of the other values as the Builder(CsvSchema src) constructor does.