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(); git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1460254 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
68f4892138
commit
6b2a504564
|
@ -470,6 +470,15 @@ public class CSVFormat implements Serializable {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a builder based on this format.
|
||||||
|
*
|
||||||
|
* @return a new builder
|
||||||
|
*/
|
||||||
|
public CSVFormatBuilder toBuilder() {
|
||||||
|
return new CSVFormatBuilder(this);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds CSVFormat objects.
|
* Builds CSVFormat objects.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -59,6 +59,8 @@ public class CSVFormatBuilderTest {
|
||||||
public void testCopiedFormatWithChanges() {
|
public void testCopiedFormatWithChanges() {
|
||||||
final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
|
final CSVFormat newFormat = CSVFormat.newBuilder(RFC4180).withDelimiter('!').build();
|
||||||
assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
|
assertTrue(newFormat.getDelimiter() != RFC4180.getDelimiter());
|
||||||
|
final CSVFormat newFormat2 = RFC4180.toBuilder().withDelimiter('!').build();
|
||||||
|
assertTrue(newFormat2.getDelimiter() != RFC4180.getDelimiter());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue