class MonitoringStatsWriter {

    public String convertStatsToCsvString(final List<MonitoringStats> stats) {
        if (CollectionUtils.isEmpty(stats)) {
            return StringUtils.EMPTY;
        }
        final StringWriter stringWriter = new StringWriter();
        final CSVWriter csvWriter = new CSVWriter(stringWriter);
        final List<String[]> allLines = extractTable(stats);
        csvWriter.writeAll(allLines);
        return stringWriter.toString();
    }

}