|
@@ -78,16 +78,19 @@ public class CSVResultHandlerServiceImpl implements ResultHandlerService {
|
78
|
78
|
}
|
79
|
79
|
|
80
|
80
|
@Override
|
81
|
|
- public <T> void resultHandler(List<T> dataList, Class<T> cls) throws Exception {
|
|
81
|
+ public <T> void resultHandler(List<T> dataList) throws Exception {
|
82
|
82
|
checkFile();
|
83
|
83
|
|
84
|
84
|
logger.debug("start write to csv file size = {}", dataList.size());
|
85
|
85
|
|
86
|
86
|
long startTime = System.currentTimeMillis();
|
87
|
87
|
|
|
88
|
+
|
|
89
|
+ Class<?> cls = Object.class;
|
|
90
|
+
|
88
|
91
|
for (T t : dataList) {
|
|
92
|
+ cls = t.getClass();
|
89
|
93
|
Object[] row;
|
90
|
|
-
|
91
|
94
|
if (t.getClass().isArray()) {
|
92
|
95
|
row = (Object[]) t;
|
93
|
96
|
} else if (List.class.isAssignableFrom(t.getClass())) {
|
|
@@ -95,7 +98,8 @@ public class CSVResultHandlerServiceImpl implements ResultHandlerService {
|
95
|
98
|
row = ((List) t).toArray();
|
96
|
99
|
} else {
|
97
|
100
|
// auto mapper
|
98
|
|
- row = resultMapper(t, cls);
|
|
101
|
+ //noinspection unchecked
|
|
102
|
+ row = resultMapper(t, (Class<T>) t.getClass());
|
99
|
103
|
}
|
100
|
104
|
Object[] handlerRow = toCsvContent(row);
|
101
|
105
|
writer.printRecord(handlerRow);
|