Skip to content

Commit 589f822

Browse files
committed
Use streams.
Remove unused imports.
1 parent 9de125e commit 589f822

2 files changed

Lines changed: 4 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ public CSVPrinter(final Appendable out, final CSVFormat format) throws IOExcepti
102102
// It seems a pain to have to track whether the header has already been printed or not.
103103
if (format.getHeaderComments() != null) {
104104
for (final String line : format.getHeaderComments()) {
105-
if (line != null) {
106-
this.printComment(line);
107-
}
105+
this.printComment(line);
108106
}
109107
}
110108
if (format.getHeader() != null && !format.getSkipHeaderRecord()) {
@@ -195,7 +193,7 @@ public void print(final Object value) throws IOException {
195193
* If an I/O error occurs
196194
*/
197195
public void printComment(final String comment) throws IOException {
198-
if (!format.isCommentMarkerSet()) {
196+
if (comment == null || !format.isCommentMarkerSet()) {
199197
return;
200198
}
201199
if (!newRecord) {

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.LinkedHashMap;
2424
import java.util.List;
2525
import java.util.Map;
26-
import java.util.Map.Entry;
2726
import java.util.Objects;
2827
import java.util.stream.Stream;
2928

@@ -271,12 +270,12 @@ public <M extends Map<String, String>> M putIn(final M map) {
271270
if (getHeaderMapRaw() == null) {
272271
return map;
273272
}
274-
for (final Entry<String, Integer> entry : getHeaderMapRaw().entrySet()) {
273+
getHeaderMapRaw().entrySet().forEach(entry -> {
275274
final int col = entry.getValue().intValue();
276275
if (col < values.length) {
277276
map.put(entry.getKey(), values[col]);
278277
}
279-
}
278+
});
280279
return map;
281280
}
282281

0 commit comments

Comments
 (0)