You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2013/03/24 03:02:12 UTC
svn commit: r1460254 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVFormat.java
test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
Author: ggregory
Date: Sun Mar 24 02:02:11 2013
New Revision: 1460254
URL: http://svn.apache.org/r1460254
Log:
Add a toBuilder method to do:
CSVFormat format = CSVFormat.EXCEL.toBuilder().withHeader("Col1", "Col2", "Col3").build();
Instead of:
CSVFormat format = CSVFormat.newBuilder(CSVFormat.EXCEL).withHeader("Col1", "Col2", "Col3").build();
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1460254&r1=1460253&r2=1460254&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java Sun Mar 24 02:02:11 2013
@@ -471,6 +471,15 @@ public class CSVFormat implements Serial
}
/**
+ * Creates a builder based on this format.
+ *
+ * @return a new builder
+ */
+ public CSVFormatBuilder toBuilder() {
+ return new CSVFormatBuilder(this);
+ }
+
+ /**
* Builds CSVFormat objects.
*/
public static class CSVFormatBuilder {
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java?rev=1460254&r1=1460253&r2=1460254&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java Sun Mar 24 02:02:11 2013
@@ -59,6 +59,8 @@ public class CSVFormatBuilderTest {
public void testCopiedFormatWithChanges() {
final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
+ final CSVFormat newFormat2 = RFC4180.toBuilder().withDelimiter('!').build();
+ assertTrue(newFormat2.getDelimiter() != RFC4180.getDelimiter());
}
@Test
Re: svn commit: r1460254 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVFormat.java test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Mar 24, 2013 at 8:30 AM, sebb <se...@gmail.com> wrote:
> On 24 March 2013 02:02, <gg...@apache.org> wrote:
> > Author: ggregory
> > Date: Sun Mar 24 02:02:11 2013
> > New Revision: 1460254
> >
> > URL: http://svn.apache.org/r1460254
> > Log:
> > Add a toBuilder method to do:
> > CSVFormat format = CSVFormat.EXCEL.toBuilder().withHeader("Col1",
> "Col2", "Col3").build();
> > Instead of:
> > CSVFormat format =
> CSVFormat.newBuilder(CSVFormat.EXCEL).withHeader("Col1", "Col2",
> "Col3").build();
>
> The new syntax needs to be documented somewhere please.
> e.g. classs Javadoc
>
Ah, yes, good point, thank you. Done.
Gary
>
> > Modified:
> >
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> >
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> >
> > Modified:
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> > URL:
> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1460254&r1=1460253&r2=1460254&view=diff
> >
> ==============================================================================
> > ---
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> (original)
> > +++
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> Sun Mar 24 02:02:11 2013
> > @@ -471,6 +471,15 @@ public class CSVFormat implements Serial
> > }
> >
> > /**
> > + * Creates a builder based on this format.
> > + *
> > + * @return a new builder
> > + */
> > + public CSVFormatBuilder toBuilder() {
> > + return new CSVFormatBuilder(this);
> > + }
> > +
> > + /**
> > * Builds CSVFormat objects.
> > */
> > public static class CSVFormatBuilder {
> >
> > Modified:
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> > URL:
> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java?rev=1460254&r1=1460253&r2=1460254&view=diff
> >
> ==============================================================================
> > ---
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> (original)
> > +++
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> Sun Mar 24 02:02:11 2013
> > @@ -59,6 +59,8 @@ public class CSVFormatBuilderTest {
> > public void testCopiedFormatWithChanges() {
> > final CSVFormat newFormat =
> CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
> > assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
> > + final CSVFormat newFormat2 =
> RFC4180.toBuilder().withDelimiter('!').build();
> > + assertTrue(newFormat2.getDelimiter() != RFC4180.getDelimiter());
> > }
> >
> > @Test
> >
> >
>
> ---------------------------------------------------------------------
> 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
Re: svn commit: r1460254 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVFormat.java test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
Posted by sebb <se...@gmail.com>.
On 24 March 2013 02:02, <gg...@apache.org> wrote:
> Author: ggregory
> Date: Sun Mar 24 02:02:11 2013
> New Revision: 1460254
>
> URL: http://svn.apache.org/r1460254
> Log:
> Add a toBuilder method to do:
> CSVFormat format = CSVFormat.EXCEL.toBuilder().withHeader("Col1", "Col2", "Col3").build();
> Instead of:
> CSVFormat format = CSVFormat.newBuilder(CSVFormat.EXCEL).withHeader("Col1", "Col2", "Col3").build();
The new syntax needs to be documented somewhere please.
e.g. classs Javadoc
> Modified:
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
>
> Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1460254&r1=1460253&r2=1460254&view=diff
> ==============================================================================
> --- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java (original)
> +++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java Sun Mar 24 02:02:11 2013
> @@ -471,6 +471,15 @@ public class CSVFormat implements Serial
> }
>
> /**
> + * Creates a builder based on this format.
> + *
> + * @return a new builder
> + */
> + public CSVFormatBuilder toBuilder() {
> + return new CSVFormatBuilder(this);
> + }
> +
> + /**
> * Builds CSVFormat objects.
> */
> public static class CSVFormatBuilder {
>
> Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java?rev=1460254&r1=1460253&r2=1460254&view=diff
> ==============================================================================
> --- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java (original)
> +++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java Sun Mar 24 02:02:11 2013
> @@ -59,6 +59,8 @@ public class CSVFormatBuilderTest {
> public void testCopiedFormatWithChanges() {
> final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
> assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
> + final CSVFormat newFormat2 = RFC4180.toBuilder().withDelimiter('!').build();
> + assertTrue(newFormat2.getDelimiter() != RFC4180.getDelimiter());
> }
>
> @Test
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org
Re: svn commit: r1460254 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVFormat.java test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
Posted by Gary Gregory <ga...@gmail.com>.
On Sun, Mar 24, 2013 at 9:06 AM, Benedikt Ritter <br...@apache.org> wrote:
> 2013/3/24 <gg...@apache.org>
>
> > Author: ggregory
> > Date: Sun Mar 24 02:02:11 2013
> > New Revision: 1460254
> >
> > URL: http://svn.apache.org/r1460254
> > Log:
> > Add a toBuilder method to do:
> > CSVFormat format = CSVFormat.EXCEL.toBuilder().withHeader("Col1", "Col2",
> > "Col3").build();
> > Instead of:
> > CSVFormat format =
> > CSVFormat.newBuilder(CSVFormat.EXCEL).withHeader("Col1", "Col2",
> > "Col3").build();
> >
>
> Good idea Gary! I like this.
>
Thank you BenediKt ;)
Gary
>
> >
> > Modified:
> >
> >
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> >
> >
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> >
> > Modified:
> >
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1460254&r1=1460253&r2=1460254&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> > (original)
> > +++
> >
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> > Sun Mar 24 02:02:11 2013
> > @@ -471,6 +471,15 @@ public class CSVFormat implements Serial
> > }
> >
> > /**
> > + * Creates a builder based on this format.
> > + *
> > + * @return a new builder
> > + */
> > + public CSVFormatBuilder toBuilder() {
> > + return new CSVFormatBuilder(this);
> > + }
> > +
> > + /**
> > * Builds CSVFormat objects.
> > */
> > public static class CSVFormatBuilder {
> >
> > Modified:
> >
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> > URL:
> >
> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java?rev=1460254&r1=1460253&r2=1460254&view=diff
> >
> >
> ==============================================================================
> > ---
> >
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> > (original)
> > +++
> >
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> > Sun Mar 24 02:02:11 2013
> > @@ -59,6 +59,8 @@ public class CSVFormatBuilderTest {
> > public void testCopiedFormatWithChanges() {
> > final CSVFormat newFormat =
> > CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
> > assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
> > + final CSVFormat newFormat2 =
> > RFC4180.toBuilder().withDelimiter('!').build();
> > + assertTrue(newFormat2.getDelimiter() != RFC4180.getDelimiter());
> > }
> >
> > @Test
> >
> >
> >
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>
--
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
Re: svn commit: r1460254 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/CSVFormat.java test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
Posted by Benedikt Ritter <br...@apache.org>.
2013/3/24 <gg...@apache.org>
> Author: ggregory
> Date: Sun Mar 24 02:02:11 2013
> New Revision: 1460254
>
> URL: http://svn.apache.org/r1460254
> Log:
> Add a toBuilder method to do:
> CSVFormat format = CSVFormat.EXCEL.toBuilder().withHeader("Col1", "Col2",
> "Col3").build();
> Instead of:
> CSVFormat format =
> CSVFormat.newBuilder(CSVFormat.EXCEL).withHeader("Col1", "Col2",
> "Col3").build();
>
Good idea Gary! I like this.
>
> Modified:
>
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
>
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
>
> Modified:
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1460254&r1=1460253&r2=1460254&view=diff
>
> ==============================================================================
> ---
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> (original)
> +++
> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
> Sun Mar 24 02:02:11 2013
> @@ -471,6 +471,15 @@ public class CSVFormat implements Serial
> }
>
> /**
> + * Creates a builder based on this format.
> + *
> + * @return a new builder
> + */
> + public CSVFormatBuilder toBuilder() {
> + return new CSVFormatBuilder(this);
> + }
> +
> + /**
> * Builds CSVFormat objects.
> */
> public static class CSVFormatBuilder {
>
> Modified:
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java?rev=1460254&r1=1460253&r2=1460254&view=diff
>
> ==============================================================================
> ---
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> (original)
> +++
> commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java
> Sun Mar 24 02:02:11 2013
> @@ -59,6 +59,8 @@ public class CSVFormatBuilderTest {
> public void testCopiedFormatWithChanges() {
> final CSVFormat newFormat =
> CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
> assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
> + final CSVFormat newFormat2 =
> RFC4180.toBuilder().withDelimiter('!').build();
> + assertTrue(newFormat2.getDelimiter() != RFC4180.getDelimiter());
> }
>
> @Test
>
>
>
--
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter