Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 71E509725 for ; Fri, 16 Mar 2012 13:20:04 +0000 (UTC) Received: (qmail 85179 invoked by uid 500); 16 Mar 2012 13:20:04 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 85098 invoked by uid 500); 16 Mar 2012 13:20:04 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 85088 invoked by uid 99); 16 Mar 2012 13:20:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Mar 2012 13:20:03 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Mar 2012 13:20:01 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 9F0A523B9C for ; Fri, 16 Mar 2012 13:19:40 +0000 (UTC) Date: Fri, 16 Mar 2012 13:19:40 +0000 (UTC) From: "Simone Tripodi (Commented) (JIRA)" To: issues@commons.apache.org Message-ID: <1147237002.24310.1331903980653.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <1542391558.22615.1331862514729.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Commented] (CSV-68) Use Builder pattern for CSVFormat MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/CSV-68?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13231157#comment-13231157 ] Simone Tripodi commented on CSV-68: ----------------------------------- FWIW, +1 to builder and fluent APIs > Use Builder pattern for CSVFormat > --------------------------------- > > Key: CSV-68 > URL: https://issues.apache.org/jira/browse/CSV-68 > Project: Commons CSV > Issue Type: Improvement > Reporter: Sebb > Attachments: CSV-68.patch > > > 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: > {code} > CSVFormat DEFAULT = CSVFormat.init(',') // delimiter is required > .withEncapsulator('"') > .withLeadingSpacesIgnored(true) > .withTrailingSpacesIgnored(true) > .withEmptyLinesIgnored(true) > .withLineSeparator("\r\n") // optional, as it would be the default > .build(); > CSVFormat format = CSVFormat.init(CSVFormat.DEFAULT) // alternatively start with pre-defined format > .withSurroundingSpacesIgnored(false) > .build(); > {code} > Compare this with the current syntax: > {code} > // internal syntax; not easy to determine what all the parameters do > CSVFormat DEFAULT1 = new CSVFormat(',', '"', DISABLED, DISABLED, true, true, false, true, CRLF); > // external syntax > CSVFormat format = CSVFormat.DEFAULT.withSurroundingSpacesIgnored(false); > {code} > 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: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira