class CSVGenerator {

    public static String imaRecordsToCsv(final ImaAcceptableRecordBaseline imaBaseline) {
        LOGGER.info("Retrieved and parsing all records");
        StringBuilder sb = new StringBuilder();
        for (IMABaselineRecord record : imaBaseline.getBaselineRecords()) {
            String stringHashValue;
            Digest theHash = record.getHash();
            if (theHash == null) {
                stringHashValue = "";
            } else {
                final byte[] digest = theHash.getDigest();
                final char[] hash = Hex.encodeHex(digest);
                stringHashValue = String.valueOf(hash);
            }

            sb.append("\"")
                    .append(record.getPath().replace("\"", "\"\""))
                    .append("\",")
                    .append(stringHashValue)
                    .append(System.lineSeparator());
        }
        return sb.toString();
    }

    private  CSVGenerator();

}