From da55604794b31f84eaa1a04205fe4d9a6573749c Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Mon, 20 May 2019 19:53:15 -0400 Subject: [PATCH] [CSV-239] Cannot get headers in column order from CSVRecord. CSVParser.createHeaderNames(Map) -> private and instance side. --- .../org/apache/commons/csv/CSVParser.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java b/src/main/java/org/apache/commons/csv/CSVParser.java index 95dbfc63..7b42206c 100644 --- a/src/main/java/org/apache/commons/csv/CSVParser.java +++ b/src/main/java/org/apache/commons/csv/CSVParser.java @@ -183,16 +183,6 @@ public final class CSVParser implements Iterable, Closeable { } } - static List createHeaderNames(final Map headerMap) { - // @formatter:off - return headerMap == null ? null - : headerMap.entrySet().stream() - .sorted(Map.Entry.comparingByValue()) - .map(Map.Entry::getKey) - .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); - // @formatter:on - } - /** * Creates a parser for the given {@link File}. * @@ -289,8 +279,6 @@ public final class CSVParser implements Iterable, Closeable { return new CSVParser(reader, format); } - // the following objects are shared to reduce garbage - /** * Creates a parser for the given {@link String}. * @@ -311,6 +299,8 @@ public final class CSVParser implements Iterable, Closeable { return new CSVParser(new StringReader(string), format); } + // the following objects are shared to reduce garbage + /** * Creates a parser for the given URL. * @@ -498,6 +488,16 @@ public final class CSVParser implements Iterable, Closeable { return hdrMap; } + private List createHeaderNames(final Map headerMap) { + // @formatter:off + return headerMap == null ? null + : headerMap.entrySet().stream() + .sorted(Map.Entry.comparingByValue()) + .map(Map.Entry::getKey) + .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); + // @formatter:on + } + /** * Returns the current line number in the input stream. *