io.bretty.console.table.NumberColumnFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of console-table-builder Show documentation
Show all versions of console-table-builder Show documentation
An extensible Java library to build stylish Excel-like tables, which can be converted into a single string with all table formats preserved.
The newest version!
/*
* Copyright (c) 2015 SUN XIMENG (Nathaniel). All rights reserved.
*/
package io.bretty.console.table;
class NumberColumnFormatter extends ColumnFormatter {
protected Precision precision;
protected NumberColumnFormatter(Alignment al, int width, Precision p) {
super(al, width);
this.precision = p;
}
/*protected double cast(Object n) {
return ((Number) n).doubleValue();
}*/
@Override
public String format(Number n) {
double value = n.doubleValue();
return this.formatString(this.precision.format(value), this.width);
}
}