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

sgoeschl pushed a commit to branch FREEMARKER-144
in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git


The following commit(s) were added to refs/heads/FREEMARKER-144 by this push:
     new 88ecad6  FREEMARKER-144 Proof Of Concept for providing DataFrames
88ecad6 is described below

commit 88ecad66afa57b1b4d5ad2d1e08c0ee6567501c6
Author: Siegfried Goeschl <[email protected]>
AuthorDate: Wed Jun 17 18:25:14 2020 +0200

    FREEMARKER-144 Proof Of Concept for providing DataFrames
---
 .../freemarker/generator/base/table/Table.java     | 14 ++++--
 .../freemarker/generator/base/util/ListUtils.java  |  6 ++-
 .../src/site/markdown/cli/tools/dataframe.md       | 47 ++++++++++++++++++-
 .../freemarker/generator/cli/ExamplesTest.java     |  2 +
 .../freemarker/generator/cli/ManualTest.java       |  3 +-
 .../src/test/templates/manual.ftl                  |  8 +---
 .../excel/dataframe/transform.ftl}                 | 25 ++++++----
 .../generator/tools/dataframe/DataFrameTool.java   |  9 ++--
 .../tools/dataframe/converter/ConverterUtils.java  | 54 +++++++++++++++-------
 .../tools/dataframe/converter/MapConverter.java    | 26 +++++++++--
 10 files changed, 144 insertions(+), 50 deletions(-)

diff --git 
a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/table/Table.java
 
b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/table/Table.java
index aaba268..7cf7a3e 100644
--- 
a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/table/Table.java
+++ 
b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/table/Table.java
@@ -75,7 +75,9 @@ public class Table {
     }
 
     public int getNrOfColumns() {
-        return columnNames.isEmpty() ? (values.isEmpty() ? 0 : 
values.get(0).size()) : columnNames.size();
+        return columnNames.isEmpty() ?
+                (values.isEmpty() ? 0 : values.get(0).size()) :
+                columnNames.size();
     }
 
     public int size() {
@@ -109,7 +111,7 @@ public class Table {
      * @param maps list of maps
      * @return table
      */
-    public static Table fromMaps(List<Map<String, Object>> maps) {
+    public static Table fromMaps(Collection<Map<String, Object>> maps) {
         if (maps == null || maps.isEmpty()) {
             return new Table();
         }
@@ -151,7 +153,9 @@ public class Table {
      * @return table
      */
     public static Table fromLists(List<List<Object>> lists, boolean 
withFirstRowAsColumnNames) {
-        requireNonNull(lists, "lists is null");
+        if (ListUtils.isNullOrEmpty(lists) && withFirstRowAsColumnNames) {
+            throw new IllegalArgumentException("Header columns expected but 
list is empty");
+        }
 
         if (withFirstRowAsColumnNames) {
             final List<String> columnNames = columnNames(lists.get(0));
@@ -215,7 +219,7 @@ public class Table {
      * @param columnNames column names
      * @return list of column values
      */
-    private static List<List<Object>> columnValuesList(List<Map<String, 
Object>> maps, List<String> columnNames) {
+    private static List<List<Object>> columnValuesList(Collection<Map<String, 
Object>> maps, List<String> columnNames) {
         return columnNames.stream()
                 .map(columnName -> columnValues(maps, columnName))
                 .collect(Collectors.toList());
@@ -228,7 +232,7 @@ public class Table {
      * @param columnName column name
      * @return values of the given column
      */
-    private static List<Object> columnValues(List<Map<String, Object>> maps, 
String columnName) {
+    private static List<Object> columnValues(Collection<Map<String, Object>> 
maps, String columnName) {
         return maps.stream()
                 .map(map -> map.getOrDefault(columnName, null))
                 .collect(Collectors.toList());
diff --git 
a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/ListUtils.java
 
b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/ListUtils.java
index 406a280..e04d16a 100644
--- 
a/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/ListUtils.java
+++ 
b/freemarker-generator-base/src/main/java/org/apache/freemarker/generator/base/util/ListUtils.java
@@ -22,6 +22,10 @@ import java.util.Objects;
 
 public class ListUtils {
 
+    public static <T> boolean isNullOrEmpty(final List<T> list) {
+        return list == null || list.isEmpty();
+    }
+
     /**
      * Transposes the given tabular data, swapping rows with columns.
      *
@@ -31,7 +35,7 @@ public class ListUtils {
      * @throws NullPointerException if the given table is {@code null}
      */
     public static <T> List<List<T>> transpose(final List<List<T>> table) {
-        if (table.isEmpty()) {
+        if (isNullOrEmpty(table)) {
             return new ArrayList<>();
         }
 
diff --git a/freemarker-generator-cli/src/site/markdown/cli/tools/dataframe.md 
b/freemarker-generator-cli/src/site/markdown/cli/tools/dataframe.md
index e2f04ba..c3bd6f9 100644
--- a/freemarker-generator-cli/src/site/markdown/cli/tools/dataframe.md
+++ b/freemarker-generator-cli/src/site/markdown/cli/tools/dataframe.md
@@ -10,7 +10,7 @@ Currently the following sources are supported
 * JSON arrays
 * Excel sheets (to be done)
 
-## Examples
+## CSV Examples
 
 
[nRo/DataFrame]("https://raw.githubusercontent.com/nRo/DataFrame/master/src/test/resources/users.csv";)
 provides the following CSV file
 
@@ -127,4 +127,49 @@ which results in
 ├────────────┼────────────┤
 │45          │USA         │
 └────────────┴────────────┘
+```
+
+## JSON Examples
+
+Here we load a `site/samples/json/github-users.json` which represents a 
tabular data be 
+being parsed as a list of maps and print the JSOB as dataframe
+
+```
+./bin/freemarker-cli \
+  -i 
'${DataFrameTool.print(DataFrameTool.fromMaps(GsonTool.parse(DataSources.get(0))))}'
 \
+  site/sample/json/github-users.json
+
+┌────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┐
+│#login      │#id         │#avatar_ur  │#gravatar_  │#url        │#html_url   
│#followers  │#following  │#gists_url  │#starred_u  │#subscript  │#organizat  
│#repos_url  │#events_ur  │#received_  │#type       │#site_admi  │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│mojombo     │1.00000000  │https:/...  │            │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │https:/...  │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │User        │false       │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│defunkt     │2.00000000  │https:/...  │            │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │https:/...  │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │User        │true        │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│pjhyett     │3.00000000  │https:/...  │            │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │https:/...  │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │User        │true        │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│wycats      │4.00000000  │https:/...  │            │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │https:/...  │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │User        │false       │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│ezmobius    │5.00000000  │https:/...  │            │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │https:/...  │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │User        │false       │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│ivey        │6.00000000  │https:/...  │            │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │https:/...  │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │User        │false       │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│evanphx     │7.00000000  │https:/...  │            │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │https:/...  │https:/...  │https:/...  
│https:/...  │https:/...  │https:/...  │User        │false       │
+└────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┘
+```
+
+## Excel Examples
+
+Let's transform an Excel Sheet to a dataframe being printed
+
+```
+./bin/freemarker-cli -t templates/excel/dataframe/transform.ftl 
site/sample/excel/test.xls
+
+┌────────────┬────────────┬────────────┬────────────┬────────────┬────────────┬────────────┐
+│#Text       │#Date       │#Number     │#Currency   │#Time       │#Percentag  
│#Forumula   │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│Row 1       │01/01/17    │100.00      │€100.00     │10:00       │50.00%      
│C2*F2       │
+├────────────┼────────────┼────────────┼────────────┼────────────┼────────────┼────────────┤
+│Row 2       │01/01/17    │100.00      │€100.00     │10:00       │50.00%      
│C3*F3       │
+└────────────┴────────────┴────────────┴────────────┴────────────┴────────────┴────────────┘
 ```
\ No newline at end of file
diff --git 
a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
 
b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
index ff787c1..95c7241 100644
--- 
a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
+++ 
b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ExamplesTest.java
@@ -62,6 +62,7 @@ public class ExamplesTest extends AbstractMainTest {
         assertValid(execute("-t templates/excel/md/transform.ftl 
site/sample/excel/test-multiple-sheets.xlsx"));
         assertValid(execute("-t templates/excel/csv/transform.ftl 
site/sample/excel/test-multiple-sheets.xlsx"));
         assertValid(execute("-t templates/excel/csv/custom.ftl 
-Pcsv.format=MYSQL site/sample/excel/test.xls"));
+        assertValid(execute("-t templates/excel/dataframe/transform.ftl 
site/sample/excel/test.xls"));
     }
 
     @Test
@@ -116,6 +117,7 @@ public class ExamplesTest extends AbstractMainTest {
         assertValid(execute("-i ${GsonTool.toJson(yaml)} -m 
yaml=site/sample/yaml/swagger-spec.yaml"));
         assertValid(execute("-i 
${YamlTool.toYaml(GsonTool.parse(DataSources.get(0)))} 
site/sample/json/swagger-spec.json"));
         assertValid(execute("-i ${YamlTool.toYaml(json)} -m 
json=site/sample/json/swagger-spec.json"));
+        assertValid(execute("-i 
${DataFrameTool.print(DataFrameTool.fromMaps(GsonTool.parse(DataSources.get(0))))}
 site/sample/json/github-users.json"));
     }
 
     @Test
diff --git 
a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ManualTest.java
 
b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ManualTest.java
index ab9ceb9..5fed83b 100644
--- 
a/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ManualTest.java
+++ 
b/freemarker-generator-cli/src/test/java/org/apache/freemarker/generator/cli/ManualTest.java
@@ -48,8 +48,9 @@ public class ManualTest {
     // private static final String CMD = "-b ./src/test -t templates/demo.ftl 
-m env=./site/sample/properties/user_0001/user.properties";
     // private static final String CMD = "-b ./src/test -t templates/demo.ftl 
-m ./site/sample/properties/user_0001/user.properties";
     // private static final String CMD = "-b ./src/test --data-model 
post=https://jsonplaceholder.typicode.com/posts/2 -t templates/info.ftl";
-    private static final String CMD = "-DCSV_TOOL_DELIMITER=SEMICOLON 
-DCSV_TOOL_HEADERS=true -b ./src/test -t templates/dataframe/example.ftl 
https://raw.githubusercontent.com/nRo/DataFrame/master/src/test/resources/users.csv";;
+    // private static final String CMD = "-DCSV_TOOL_DELIMITER=SEMICOLON 
-DCSV_TOOL_HEADERS=true -b ./src/test -t templates/dataframe/example.ftl 
https://raw.githubusercontent.com/nRo/DataFrame/master/src/test/resources/users.csv";;
     // private static final String CMD = "-b ./src/test -t site/template/ -m 
nginx.yaml";
+    private static final String CMD = "-b ./src/test -t 
templates/excel/dataframe/transform.ftl site/sample/excel/test.xls";
 
 
     public static void main(String[] args) {
diff --git a/freemarker-generator-cli/src/test/templates/manual.ftl 
b/freemarker-generator-cli/src/test/templates/manual.ftl
index d33edf4..b381b05 100644
--- a/freemarker-generator-cli/src/test/templates/manual.ftl
+++ b/freemarker-generator-cli/src/test/templates/manual.ftl
@@ -17,10 +17,4 @@
 -->
 Manual Test
 ---------------------------------------------------------------------------
-<#assign smallNumber = 3.1415927>
-<#assign largeNumber = 99999.99>
-
-Small Number :  ${smallNumber}
-Large Number :  ${largeNumber}
-Date         :  ${.now?date}
-Time         :  ${.now?time}
+<#assign 
df=DataFrameTool.fromMaps(GsonTool.parse(DataSources.get(0)))>${DataFrameTool.print(df)}
\ No newline at end of file
diff --git a/freemarker-generator-cli/src/test/templates/manual.ftl 
b/freemarker-generator-cli/templates/excel/dataframe/transform.ftl
similarity index 51%
copy from freemarker-generator-cli/src/test/templates/manual.ftl
copy to freemarker-generator-cli/templates/excel/dataframe/transform.ftl
index d33edf4..46eb8d5 100644
--- a/freemarker-generator-cli/src/test/templates/manual.ftl
+++ b/freemarker-generator-cli/templates/excel/dataframe/transform.ftl
@@ -15,12 +15,21 @@
   specific language governing permissions and limitations
   under the License.
 -->
-Manual Test
----------------------------------------------------------------------------
-<#assign smallNumber = 3.1415927>
-<#assign largeNumber = 99999.99>
+<#assign dataSource = DataSources.get(0)>
+<#assign name = dataSource.name>
+<#assign workbook = ExcelTool.parse(dataSource)>
+<#assign date = .now?iso_utc>
+<#--------------------------------------------------------------------------->
+<@writeSheets workbook/>
 
-Small Number :  ${smallNumber}
-Large Number :  ${largeNumber}
-Date         :  ${.now?date}
-Time         :  ${.now?time}
+<#--------------------------------------------------------------------------->
+<#-- writeSheets                                                           -->
+<#--------------------------------------------------------------------------->
+<#macro writeSheets workbook>
+    <#assign sheets = ExcelTool.getSheets(workbook)>
+    <#list sheets as sheet>
+        <#assign table = ExcelTool.toTable(sheet)>
+        <#assign df = DataFrameTool.fromLists(table, true)>
+        ${DataFrameTool.print(df)}<#t>
+    </#list>
+</#macro>
diff --git 
a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/DataFrameTool.java
 
b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/DataFrameTool.java
index 0b75936..49a7cba 100644
--- 
a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/DataFrameTool.java
+++ 
b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/DataFrameTool.java
@@ -18,8 +18,6 @@ package org.apache.freemarker.generator.tools.dataframe;
 
 import de.unknownreality.dataframe.DataFrame;
 import de.unknownreality.dataframe.DataFrameWriter;
-import de.unknownreality.dataframe.print.Printer;
-import de.unknownreality.dataframe.print.PrinterBuilder;
 import de.unknownreality.dataframe.sort.SortColumn.Direction;
 import de.unknownreality.dataframe.transform.ColumnDataFrameTransform;
 import de.unknownreality.dataframe.transform.CountTransformer;
@@ -33,6 +31,8 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import static de.unknownreality.dataframe.DataFrameWriter.DEFAULT_PRINT_FORMAT;
+
 /**
  * Create and manipulate data frame (tabular data structure). Data frames allow
  * easy manipulation and transformation of data, e.g. joining two data frames.
@@ -41,7 +41,7 @@ import java.util.Map;
 public class DataFrameTool {
 
     /**
-     * Create a data frame from  Apache Commons CSVParser.
+     * Create a data frame from Apache Commons CSVParser.
      *
      * @param csvParser CSV Parser
      * @return data frame
@@ -101,8 +101,7 @@ public class DataFrameTool {
      */
     public String print(DataFrame dataFrame) {
         final StringWriter writer = new StringWriter();
-        final Printer printer = 
PrinterBuilder.create().withAutoWidth(dataFrame.getHeader()).build();
-        DataFrameWriter.write(writer, dataFrame, printer);
+        DataFrameWriter.write(writer, dataFrame, DEFAULT_PRINT_FORMAT);
         return writer.toString();
     }
 
diff --git 
a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/ConverterUtils.java
 
b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/ConverterUtils.java
index c6d05af..5237f52 100644
--- 
a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/ConverterUtils.java
+++ 
b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/ConverterUtils.java
@@ -1,3 +1,19 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.freemarker.generator.tools.dataframe.converter;
 
 import de.unknownreality.dataframe.DataFrame;
@@ -25,36 +41,36 @@ public class ConverterUtils {
         return result;
     }
 
-    private static DataFrameBuilder addColumn(DataFrameBuilder builder, String 
name, Class<?> clazz) {
-        switch (clazz.getName()) {
+    private static DataFrameBuilder addColumn(DataFrameBuilder builder, String 
columnName, Class<?> columnType) {
+        switch (columnType.getName()) {
             case "java.lang.Boolean":
-                return builder.addBooleanColumn(name);
+                return builder.addBooleanColumn(columnName);
             case "java.lang.Byte":
-                return builder.addByteColumn(name);
+                return builder.addByteColumn(columnName);
             case "java.lang.Double":
-                return builder.addDoubleColumn(name);
+                return builder.addDoubleColumn(columnName);
             case "java.lang.Float":
-                return builder.addFloatColumn(name);
+                return builder.addFloatColumn(columnName);
             case "java.lang.Integer":
-                return builder.addIntegerColumn(name);
+                return builder.addIntegerColumn(columnName);
             case "java.lang.Long":
-                return builder.addLongColumn(name);
+                return builder.addLongColumn(columnName);
             case "java.lang.Short":
-                return builder.addShortColumn(name);
+                return builder.addShortColumn(columnName);
             case "java.lang.String":
-                return builder.addStringColumn(name);
+                return builder.addStringColumn(columnName);
             case "java.time.LocalDate":
-                return builder.addStringColumn(name);
+                return builder.addStringColumn(columnName);
             case "java.time.LocalTime":
-                return builder.addStringColumn(name);
+                return builder.addStringColumn(columnName);
             case "java.util.Date":
-                return builder.addStringColumn(name);
+                return builder.addStringColumn(columnName);
             default:
-                throw new RuntimeException("Unable to add colum for the 
following type: " + clazz.getName());
+                throw new RuntimeException("Unable to add colum for the 
following type: " + columnType.getName());
         }
     }
 
-    private static Comparable<?>[] toComparables(List<Object> values) {
+    private static Comparable<?>[] toComparables(List<?> values) {
         final int size = values.size();
         final Comparable<?>[] comparables = new Comparable<?>[size];
         for (int i = 0; i < size; i++) {
@@ -74,13 +90,17 @@ public class ConverterUtils {
 
         if (table.hasColumnHeaderRow()) {
             for (int i = 0; i < table.getColumnNames().size(); i++) {
-                addColumn(builder, table.getColumnNames().get(i), 
table.getColumnTypes().get(i));
+                final String columnName = table.getColumnNames().get(i);
+                final Class<?> columnType = table.getColumnTypes().get(i);
+                addColumn(builder, columnName, columnType);
             }
         } else {
             if (!table.isEmpty()) {
                 final List<Object> firstRecord = table.getRow(0);
                 for (int i = 0; i < firstRecord.size(); i++) {
-                    builder.addStringColumn(getAlphaColumnName(i + 1));
+                    final String columnName = getAlphaColumnName(i + 1);
+                    final Class<?> columnType = table.getColumnTypes().get(i);
+                    addColumn(builder, columnName, columnType);
                 }
             }
         }
diff --git 
a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/MapConverter.java
 
b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/MapConverter.java
index 5970920..f6800ce 100644
--- 
a/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/MapConverter.java
+++ 
b/freemarker-generator-tools/src/main/java/org/apache/freemarker/generator/tools/dataframe/converter/MapConverter.java
@@ -1,13 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.apache.freemarker.generator.tools.dataframe.converter;
 
 import de.unknownreality.dataframe.DataFrame;
-import de.unknownreality.dataframe.DataFrameBuilder;
 import org.apache.freemarker.generator.base.table.Table;
 
-import java.util.Collections;
-import java.util.List;
+import java.util.Collection;
 import java.util.Map;
 
+import static java.util.Collections.singletonList;
+
 public class MapConverter {
 
     /**
@@ -18,7 +34,7 @@ public class MapConverter {
      * @return <code>DataFrame</code>
      */
     public static DataFrame toDataFrame(Map<String, Object> map) {
-        return toDataFrame(Collections.singletonList(map));
+        return toDataFrame(singletonList(map));
     }
 
     /**
@@ -28,7 +44,7 @@ public class MapConverter {
      * @param maps list of map to build the data frame
      * @return <code>DataFrame</code>
      */
-    public static DataFrame toDataFrame(List<Map<String, Object>> maps) {
+    public static DataFrame toDataFrame(Collection<Map<String, Object>> maps) {
         final Table table = Table.fromMaps(maps);
         return ConverterUtils.toDataFrame(table);
     }

Reply via email to