diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index d8bbd952..071d165c 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -470,6 +470,15 @@ public class CSVFormat implements Serializable { return true; } + /** + * Creates a builder based on this format. + * + * @return a new builder + */ + public CSVFormatBuilder toBuilder() { + return new CSVFormatBuilder(this); + } + /** * Builds CSVFormat objects. */ diff --git a/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java b/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java index 22530b73..f72ed65c 100644 --- a/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java +++ b/src/test/java/org/apache/commons/csv/CSVFormatBuilderTest.java @@ -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