ResultFormatter implements Serializable { public String format(Object object) { Type type = Type.CLASS_TO_TYPE.get(object.getClass()); if (type == null) { return object.toString(); } switch (type) { case FLOAT: { return format((float)((Float)object)); } case DOUBLE: { return format((double)((Double)object)); } case BYTE: { return format((byte)((Byte)object)); } case SHORT: { return format((short)((Short)object)); } case INTEGER: { return format((int)((Integer)object)); } case LONG: { return format((long)((Long)object)); } default: return object.toString(); } } ResultFormatter(); String format(Object object); String format(float val); String format(double val); String format(byte val); String format(short val); String format(int val); String format(long val); DecimalFormat getFloatFormat(); DecimalFormat getDoubleFormat(); DecimalFormat getByteFormat(); DecimalFormat getShortFormat(); DecimalFormat getIntFormat(); DecimalFormat getLongFormat(); String getDiscreteFormatString(); void setDiscreteFormatString(String discreteFormatString); String getContinuousFormatString(); void setContinuousFormatString(String continuousFormatString); String getFloatFormatString(); void setFloatFormatString(String decimalFormatString); String getDoubleFormatString(); void setDoubleFormatString(String doubleFormatString); String getIntFormatString(); void setIntFormatString(String intFormatString); String getByteFormatString(); void setByteFormatString(String byteFormatString); String getShortFormatString(); void setShortFormatString(String shortFormatString); String getLongFormatString(); void setLongFormatString(String longFormatString);  }
@Test public void testObject() { ResultFormatter adf = new ResultFormatter(); final String testString = "Hello World"; Assert.assertEquals(testString, adf.format(testString)); }
@Test public void testDefaults() { ResultFormatter adf = new ResultFormatter(); final String discreteString = "1"; Assert.assertEquals(discreteString, adf.format((byte)1)); Assert.assertEquals(discreteString, adf.format((short)1)); Assert.assertEquals(discreteString, adf.format(1)); Assert.assertEquals(discreteString, adf.format((long)1)); final String continuousString = "1.0"; Assert.assertEquals(continuousString, adf.format((float)1)); Assert.assertEquals(continuousString, adf.format((double)1)); }