// calculates the alignment to use private AsciiTableAlignment calculateAlignment(Class<?> columnType) { FormatSettings<Object> formatSettings = formatSettingsProvider.settings(columnType, defaultSettings); boolean isNumeric = formatSettings.getCategory() == FormatCategory.NUMERIC || formatSettings.getCategory() == FormatCategory.DATE; return isNumeric ? AsciiTableAlignment.RIGHT : AsciiTableAlignment.LEFT; }
/** * Formats a value into a string. * * @param value the value * @param format the format that controls how the value is formatted * @return the formatted value */ @SuppressWarnings("unchecked") protected String formatValue(Object value, ReportOutputFormat format) { Object formatValue = value instanceof Optional ? ((Optional<?>) value).orElse(null) : value; if (formatValue == null) { return ""; } FormatSettings<Object> formatSettings = formatSettingsProvider.settings(formatValue.getClass(), defaultSettings); ValueFormatter<Object> formatter = formatSettings.getFormatter(); return format == ReportOutputFormat.CSV ? formatter.formatForCsv(formatValue) : formatter.formatForDisplay(formatValue); }