NumberFormatRenderer class
Renders {@link Number} objects with a {@link NumberFormat}.
class NumberFormatRenderer extends AbstractRenderer<num> { NumberFormat format; /** * Create an instance with the given [format] or * [NumberFormat#getDecimalFormat()] */ NumberFormatRenderer([NumberFormat format = null]) { if (format == null) { this.format = NumberFormat.getDecimalFormat(); } else { this.format = format; } } String render(num object) { if (object == null) { return ""; } return format.format(object); } }
Extends
AbstractRenderer<num> > NumberFormatRenderer
Constructors
new NumberFormatRenderer([NumberFormat format = null]) #
Create an instance with the given
format or
NumberFormat#getDecimalFormat()
NumberFormatRenderer([NumberFormat format = null]) { if (format == null) { this.format = NumberFormat.getDecimalFormat(); } else { this.format = format; } }
Properties
NumberFormat format #
NumberFormat format
Methods
String render(num object) #
void renderTo(T object, Appendable appendable) #
inherited from AbstractRenderer
Renders {@code object} as plain text, appended directly to {@code appendable}. Should never throw any exceptions except if {@code appendable} throws an {@code IOException}.
void renderTo(T object, Appendable appendable) { appendable.append(render(object)); }