commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (Created) (JIRA)" <>
Subject [jira] [Created] (CSV-68) Use Builder pattern for CSVFormat
Date Fri, 16 Mar 2012 01:48:34 GMT
Use Builder pattern for CSVFormat

                 Key: CSV-68
             Project: Commons CSV
          Issue Type: Improvement
            Reporter: Sebb

Using a builder pattern to create CSVFormat instances would allow the settings to be validated
at creation time and would eliminate the need to keep creating new CSVFormat instances whilst
still allowing the class to be immutable.

A possible API is as follows:

CSVFormat DEFAULT = CSVFormat.init(',') // delimiter is required
        .withLineSeparator("\r\n") // optional, as it would be the default

CSVFormat format = CSVFormat.init(CSVFormat.DEFAULT) // alternatively start with pre-defined

Compare this with the current syntax:

// internal syntax; not easy to determine what all the parameters do
CSVFormat DEFAULT1 = new CSVFormat(',', '"', DISABLED, DISABLED, true, true, false, true,

// external syntax
CSVFormat format = CSVFormat.DEFAULT.withSurroundingSpacesIgnored(false);

As a proof of concept I've written skeleton code which compiles (but needs completing).

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:!default.jspa
For more information on JIRA, see:


View raw message