This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git


The following commit(s) were added to refs/heads/master by this push:
     new 4e90cdf  * Replace For loop with map.forEach (#172)
4e90cdf is described below

commit 4e90cdfdafa3ad4fa1946cd72c7cb968dad39279
Author: Arturo Bernal <[email protected]>
AuthorDate: Fri Oct 22 16:32:22 2021 +0200

    * Replace For loop with map.forEach (#172)
    
    * Use diamond type <>
    * Extract commons expressions
---
 src/main/java/org/apache/commons/csv/CSVRecord.java     | 8 ++++----
 src/main/java/org/apache/commons/csv/Lexer.java         | 4 ++--
 src/test/java/org/apache/commons/csv/CSVRecordTest.java | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/main/java/org/apache/commons/csv/CSVRecord.java 
b/src/main/java/org/apache/commons/csv/CSVRecord.java
index a8aa082..e76bbc4 100644
--- a/src/main/java/org/apache/commons/csv/CSVRecord.java
+++ b/src/main/java/org/apache/commons/csv/CSVRecord.java
@@ -270,10 +270,10 @@ public final class CSVRecord implements Serializable, 
Iterable<String> {
         if (getHeaderMapRaw() == null) {
             return map;
         }
-        getHeaderMapRaw().entrySet().forEach(entry -> {
-            final int col = entry.getValue().intValue();
+        getHeaderMapRaw().forEach((key, value) -> {
+            final int col = value;
             if (col < values.length) {
-                map.put(entry.getKey(), values[col]);
+                map.put(key, values[col]);
             }
         });
         return map;
@@ -314,7 +314,7 @@ public final class CSVRecord implements Serializable, 
Iterable<String> {
      * @return A new Map. The map is empty if the record has no headers.
      */
     public Map<String, String> toMap() {
-        return putIn(new LinkedHashMap<String, String>(values.length));
+        return putIn(new LinkedHashMap<>(values.length));
     }
 
     /**
diff --git a/src/main/java/org/apache/commons/csv/Lexer.java 
b/src/main/java/org/apache/commons/csv/Lexer.java
index a8afc50..edd9576 100644
--- a/src/main/java/org/apache/commons/csv/Lexer.java
+++ b/src/main/java/org/apache/commons/csv/Lexer.java
@@ -413,6 +413,7 @@ final class Lexer implements Closeable {
                 token.type = TOKEN;
                 break;
             }
+            // continue
             if (isEscape(ch)) {
                 if (isEscapeDelimiter()) {
                     token.content.append(delimiter);
@@ -424,11 +425,10 @@ final class Lexer implements Closeable {
                         token.content.append((char) unescaped);
                     }
                 }
-                ch = reader.read(); // continue
             } else {
                 token.content.append((char) ch);
-                ch = reader.read(); // continue
             }
+            ch = reader.read(); // continue
         }
 
         if (ignoreSurroundingSpaces) {
diff --git a/src/test/java/org/apache/commons/csv/CSVRecordTest.java 
b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
index 39b02ba..8a92a7e 100644
--- a/src/test/java/org/apache/commons/csv/CSVRecordTest.java
+++ b/src/test/java/org/apache/commons/csv/CSVRecordTest.java
@@ -207,7 +207,7 @@ public class CSVRecordTest {
         this.recordWithHeader.putIn(map);
         this.validateMap(map, false);
         // Test that we can compile with assignment to the same map as the 
param.
-        final TreeMap<String, String> map2 = recordWithHeader.putIn(new 
TreeMap<String, String>());
+        final TreeMap<String, String> map2 = recordWithHeader.putIn(new 
TreeMap<>());
         this.validateMap(map2, false);
     }
 

Reply via email to