Skip to content

Commit aa0fbb0

Browse files
committed
[CSV-157] Add enum CSVFormat.Predefined that contains the default CSVFormat values.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1695179 13f79535-47bb-0310-9956-ffa450edef68
1 parent fd3a986 commit aa0fbb0

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,18 @@ public static CSVFormat newFormat(final char delimiter) {
364364
return new CSVFormat(delimiter, null, null, null, null, false, false, null, null, null, null, false, false);
365365
}
366366

367+
/**
368+
* Gets one of the predefined formats from {@link CSVFormat.Predefined}.
369+
*
370+
* @param format
371+
* name
372+
* @return one of the predefined formats
373+
* @since 1.2
374+
*/
375+
public static CSVFormat valueOf(final String format) {
376+
return CSVFormat.Predefined.valueOf(format).getFormat();
377+
}
378+
367379
/**
368380
* Creates a customized CSV format.
369381
*

src/test/java/org/apache/commons/csv/CSVFormatPredefinedTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class CSVFormatPredefinedTest {
2727

2828
private void test(final CSVFormat format, final String enumName) {
2929
Assert.assertEquals(format, CSVFormat.Predefined.valueOf(enumName).getFormat());
30+
Assert.assertEquals(format, CSVFormat.valueOf(enumName));
3031
}
3132

3233
@Test

0 commit comments

Comments
 (0)