Skip to content

Commit 4e90cdf

Browse files
* Replace For loop with map.forEach (apache#172)
* Use diamond type <> * Extract commons expressions
1 parent 9d7f830 commit 4e90cdf

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ public <M extends Map<String, String>> M putIn(final M map) {
270270
if (getHeaderMapRaw() == null) {
271271
return map;
272272
}
273-
getHeaderMapRaw().entrySet().forEach(entry -> {
274-
final int col = entry.getValue().intValue();
273+
getHeaderMapRaw().forEach((key, value) -> {
274+
final int col = value;
275275
if (col < values.length) {
276-
map.put(entry.getKey(), values[col]);
276+
map.put(key, values[col]);
277277
}
278278
});
279279
return map;
@@ -314,7 +314,7 @@ public List<String> toList() {
314314
* @return A new Map. The map is empty if the record has no headers.
315315
*/
316316
public Map<String, String> toMap() {
317-
return putIn(new LinkedHashMap<String, String>(values.length));
317+
return putIn(new LinkedHashMap<>(values.length));
318318
}
319319

320320
/**

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ private Token parseSimpleToken(final Token token, int ch) throws IOException {
413413
token.type = TOKEN;
414414
break;
415415
}
416+
// continue
416417
if (isEscape(ch)) {
417418
if (isEscapeDelimiter()) {
418419
token.content.append(delimiter);
@@ -424,11 +425,10 @@ private Token parseSimpleToken(final Token token, int ch) throws IOException {
424425
token.content.append((char) unescaped);
425426
}
426427
}
427-
ch = reader.read(); // continue
428428
} else {
429429
token.content.append((char) ch);
430-
ch = reader.read(); // continue
431430
}
431+
ch = reader.read(); // continue
432432
}
433433

434434
if (ignoreSurroundingSpaces) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ public void testPutInMap() {
207207
this.recordWithHeader.putIn(map);
208208
this.validateMap(map, false);
209209
// Test that we can compile with assignment to the same map as the param.
210-
final TreeMap<String, String> map2 = recordWithHeader.putIn(new TreeMap<String, String>());
210+
final TreeMap<String, String> map2 = recordWithHeader.putIn(new TreeMap<>());
211211
this.validateMap(map2, false);
212212
}
213213

0 commit comments

Comments
 (0)