class CSVGenerator {

    public static String blacklistToCsv(final ImaBlacklistBaseline blacklistBaseline) {
        StringBuilder sb = new StringBuilder();
        CSVPrinter csvPrinter;
        try {
            csvPrinter = CSVFormat.DEFAULT.withRecordSeparator(System.lineSeparator()).print(sb);
            for (ImaBlacklistRecord record : blacklistBaseline.getRecords()) {
                String digest = "";
                Digest hash = record.getHash();
                if (hash != null) {
                    digest = hash.toString();
                }
                csvPrinter.printRecord(
                        nullToEmpty(record.getPath()),
                        digest,
                        nullToEmpty(record.getDescription())
                );
            }
        } catch (IOException e) {
            throw new RuntimeException("Could not instantiate CSV printer");
        }
        return sb.toString();
    }

    private  CSVGenerator();

}