You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by br...@apache.org on 2018/09/19 09:04:57 UTC

[40/48] commons-csv git commit: Remove duplicated code by calling printRecords(Iterable)

Remove duplicated code by calling printRecords(Iterable)


Project: http://git-wip-us.apache.org/repos/asf/commons-csv/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-csv/commit/7694e8f9
Tree: http://git-wip-us.apache.org/repos/asf/commons-csv/tree/7694e8f9
Diff: http://git-wip-us.apache.org/repos/asf/commons-csv/diff/7694e8f9

Branch: refs/heads/release
Commit: 7694e8f99972f33b2e285ea2652a1b21a1c6b653
Parents: 676a580
Author: Benedikt Ritter <br...@apache.org>
Authored: Tue Aug 21 22:05:47 2018 +0200
Committer: Benedikt Ritter <br...@apache.org>
Committed: Tue Aug 21 22:05:47 2018 +0200

----------------------------------------------------------------------
 src/main/java/org/apache/commons/csv/CSVPrinter.java | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-csv/blob/7694e8f9/src/main/java/org/apache/commons/csv/CSVPrinter.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java
index d639c60..3ae5971 100644
--- a/src/main/java/org/apache/commons/csv/CSVPrinter.java
+++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java
@@ -26,6 +26,7 @@ import java.io.Flushable;
 import java.io.IOException;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.Arrays;
 
 /**
  * Prints values in a CSV format.
@@ -321,15 +322,7 @@ public final class CSVPrinter implements Flushable, Closeable {
      *             If an I/O error occurs
      */
     public void printRecords(final Object... values) throws IOException {
-        for (final Object value : values) {
-            if (value instanceof Object[]) {
-                this.printRecord((Object[]) value);
-            } else if (value instanceof Iterable) {
-                this.printRecord((Iterable<?>) value);
-            } else {
-                this.printRecord(value);
-            }
-        }
+        printRecords(Arrays.asList(values));
     }
 
     /**