[CSV-239] Cannot get headers in column order from CSVRecord.

CSVParser.createHeaderNames(Map<String, Integer>) -> private and
instance side.
This commit is contained in:
Gary Gregory 2019-05-20 19:53:15 -04:00
parent 6fd5179244
commit da55604794
1 changed files with 12 additions and 12 deletions

View File

@ -183,16 +183,6 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
} }
} }
static List<String> createHeaderNames(final Map<String, Integer> 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}. * Creates a parser for the given {@link File}.
* *
@ -289,8 +279,6 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
return new CSVParser(reader, format); return new CSVParser(reader, format);
} }
// the following objects are shared to reduce garbage
/** /**
* Creates a parser for the given {@link String}. * Creates a parser for the given {@link String}.
* *
@ -311,6 +299,8 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
return new CSVParser(new StringReader(string), format); return new CSVParser(new StringReader(string), format);
} }
// the following objects are shared to reduce garbage
/** /**
* Creates a parser for the given URL. * Creates a parser for the given URL.
* *
@ -498,6 +488,16 @@ public final class CSVParser implements Iterable<CSVRecord>, Closeable {
return hdrMap; return hdrMap;
} }
private List<String> createHeaderNames(final Map<String, Integer> 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. * Returns the current line number in the input stream.
* *