class CsvFormatter {

    public String format(Row row) {
        StringBuilder sbd = new StringBuilder();
        for (int i = 0; i < row.getArity(); i++) {
            if (i > 0) {
                sbd.append(fieldDelim);
            }
            Object v = row.getField(i);
            if (v == null) {
                continue;
            }
            if (quoteChar != null && types[i].equals(Types.STRING)) {
                String str = (String) v;
                if (str.isEmpty() || str.contains(fieldDelim) || str.contains(quoteChar)) {
                    sbd.append(quoteChar);
                    sbd.append(str.replace(quoteChar, escapeChar + quoteChar));
                    sbd.append(quoteChar);
                } else {
                    sbd.append(v.toString());
                }
            } else {
                sbd.append(v.toString());
            }
        }
        return sbd.toString();
    }

    public  CsvFormatter(TypeInformation[] types, String fieldDelim, @Nullable Character quoteChar);

}