Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Add fluent addColumns operation to CsvSchema.Builder #130

Closed
ansell opened this issue Aug 23, 2016 · 1 comment
Closed

Add fluent addColumns operation to CsvSchema.Builder #130

ansell opened this issue Aug 23, 2016 · 1 comment
Milestone

Comments

@ansell
Copy link
Contributor

ansell commented Aug 23, 2016

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.

@cowtowncoder cowtowncoder added this to the 2.9.0 milestone Aug 25, 2016
@cowtowncoder
Copy link
Member

Fixed via #131 and as per comments, officially included in 2.9, but technically will be included in 2.8.2 already (just not documented). This because master hasn't yet moved to 2.9.0-SNAPSHOT (will do so within next week or so).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants