Skip to content

Commit da55604

Browse files
author
Gary Gregory
committed
[CSV-239] Cannot get headers in column order from CSVRecord.
CSVParser.createHeaderNames(Map<String, Integer>) -> private and instance side.
1 parent 6fd5179 commit da55604

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,6 @@ public void remove() {
183183
}
184184
}
185185

186-
static List<String> createHeaderNames(final Map<String, Integer> headerMap) {
187-
// @formatter:off
188-
return headerMap == null ? null
189-
: headerMap.entrySet().stream()
190-
.sorted(Map.Entry.comparingByValue())
191-
.map(Map.Entry::getKey)
192-
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
193-
// @formatter:on
194-
}
195-
196186
/**
197187
* Creates a parser for the given {@link File}.
198188
*
@@ -289,8 +279,6 @@ public static CSVParser parse(final Reader reader, final CSVFormat format) throw
289279
return new CSVParser(reader, format);
290280
}
291281

292-
// the following objects are shared to reduce garbage
293-
294282
/**
295283
* Creates a parser for the given {@link String}.
296284
*
@@ -311,6 +299,8 @@ public static CSVParser parse(final String string, final CSVFormat format) throw
311299
return new CSVParser(new StringReader(string), format);
312300
}
313301

302+
// the following objects are shared to reduce garbage
303+
314304
/**
315305
* Creates a parser for the given URL.
316306
*
@@ -498,6 +488,16 @@ private Map<String, Integer> createHeaderMap() throws IOException {
498488
return hdrMap;
499489
}
500490

491+
private List<String> createHeaderNames(final Map<String, Integer> headerMap) {
492+
// @formatter:off
493+
return headerMap == null ? null
494+
: headerMap.entrySet().stream()
495+
.sorted(Map.Entry.comparingByValue())
496+
.map(Map.Entry::getKey)
497+
.collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList));
498+
// @formatter:on
499+
}
500+
501501
/**
502502
* Returns the current line number in the input stream.
503503
*

0 commit comments

Comments
 (0)