### Question:
NumberComparator implements Comparator<Object> { public static Number toNumber(Object value) { if (value == null) { return null; } else if (value instanceof Number) { return (Number) value; } else if (value instanceof Boolean) { if (Boolean.TRUE.equals(value)) { return 1; } else { return 0; } } else { final String stringValue = value.toString().trim(); if (stringValue.isEmpty()) { return null; } try { return Integer.parseInt(stringValue); } catch (NumberFormatException e) { } try { return Long.parseLong(stringValue); } catch (NumberFormatException e) { } try { return new BigInteger(stringValue); } catch (NumberFormatException e) { } try { return Double.parseDouble(stringValue); } catch (NumberFormatException e) { } { if ("true".equalsIgnoreCase(stringValue)) { return 1; } if ("false".equalsIgnoreCase(stringValue)) { return 0; } } logger.warn("Could not convert '{}' to number, returning null", value); return null; } } private  NumberComparator(); static Comparator<Object> getComparator(); static Comparable<Object> getComparable(Object o); int compare(Object o1, Object o2); static boolean isIntegerType(Number n); static Number toNumber(Object value);  }### Answer:
@Test public void testToNumberInt() throws Exception { assertEquals(4212, NumberComparator.toNumber("4212")); }
@Test public void testToNumberLong() throws Exception { assertEquals(4212000000l, NumberComparator.toNumber("4212000000")); }
@Test public void testToNumberBigInteger() throws Exception { assertEquals(new BigInteger("42120000000000004212"), NumberComparator.toNumber("42120000000000004212")); }
@Test public void testToNumberDouble() throws Exception { assertEquals(42.12, NumberComparator.toNumber("42.12")); }