commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: [CSV] Should the Builder API be optional?
Date Tue, 26 Mar 2013 16:49:23 GMT
On Tue, Mar 26, 2013 at 12:35 PM, sebb <sebbaz@gmail.com> wrote:

> On 26 March 2013 16:18, Benedikt Ritter <britter@apache.org> wrote:
> > 2013/3/26 Gary Gregory <garydgregory@gmail.com>
> >
> >> On Tue, Mar 26, 2013 at 12:03 PM, Emmanuel Bourg <ebourg@apache.org>
> >> wrote:
> >>
> >> > Le 26/03/2013 16:58, Gary Gregory a écrit :
> >> >
> >> > > Is it worth providing this shortcut:
> >> > >
> >> > > Iterable<CSVRecord> parse = CSVFormat.newBuilder().
> >> > >
> withCommentStart('#').withDelimiter('\t').withQuoteChar('"').parse(in);
> >> > >
> >> > > the builder would implement parse()
> >> >
> >> > I still think the builder is useless. My initial implementation looked
> >> > like this:
> >> >
> >> > Iterable<CSVRecord> parse =
> >> >
> >> >
> >>
> CSVFormat.DEFAULT.withCommentStart('#').withDelimiter('\t').withQuoteChar('"').parse(in);
> >> >
> >> > So yes, in this spirit the builder should implement parse(). But I
> would
> >> > prefer no builder at all.
> >> >
> >>
> >> By adding parse to the builder, we can make the builder less visible. I
> >> think I'll add that.
> >>
> >
> > This was my attention when I initially created the patch for the builder.
> > the newBuilder() method was called newFormat() back then. We changed it
> to
> > not confuse users with what objects they are dealing with. With
> > newBuilder() changed back to newFormat() again it would become:
> >
> > Iterable<CSVRecord> parse =
> >
> CSVFormat.newFormat().withCommentStart('#').withDelimiter('\t').withQuoteChar("'").parse(in);
>
> So effectively parse would do the build and then use it for the parse?
>

Yes (in SVN now) but I prefer:

CSVFormat.DEFAULT.withCommentStart('#').withDelimiter('\t').withQuoteChar("'").parse(in);

which does not create the need for calling newBuilder() and makes it
obvious what it is I am building.

Gary


> Is there a use-case for re-using the format without having to re-create it?
> If so, how would that look?
>
> > Benedikt
> >
> >
> >>
> >> Gary
> >>
> >> >
> >> > Emmanuel Bourg
> >> >
> >> >
> >> >
> >>
> >>
> >> --
> >> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> >> JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
> >> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> >> Blog: http://garygregory.wordpress.com
> >> Home: http://garygregory.com/
> >> Tweet! http://twitter.com/GaryGregory
> >>
> >
> >
> >
> > --
> > http://people.apache.org/~britter/
> > http://www.systemoutprintln.de/
> > http://twitter.com/BenediktRitter
> > http://github.com/britter
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message